在下面的代码中为:
String marketUUid = "bc76b7a5-3166-11e6-b8fe-ec9a74f8851a";
String filePath = imagePath + "/" + marketUUid + "/" + "banners";
File checkMarketBannerFolder = new File(filePath);
当我尝试将concat
marketUUid与imagePath
等其他变量合并并将其放到filePath
时,将其从此操作中移除并且我没有该变量,这意味着之后合并变量my filePath
:
/storage/emulated/0/Signal/image/banners
但是这段代码没有任何问题:
String filePath = imagePath + "/" + "bc76b7a5-3166-11e6-b8fe-ec9a74f8851a" + "/" + "banners";
什么事发生?
答案 0 :(得分:0)
格式化字符串有一种更简洁易读的方式:
String marketUUid = "bc76b7a5-3166-11e6-b8fe-ec9a74f8851a";
String imagePath = "image";
String filePath = String.format(
"%s/%s/banners",
imagePath,
marketUUid
);