下面给我一个FileNotFoundException: Invalid file path
String fileName = "folder/file" + "." + this.ext;
try {
File file = new File(fileName);
} catch(Exception e){
}
先前将this.ext设置为"txt"
的位置
[玩耍之后,我发现这很好用。
String ext = "txt";
String fileName = "folder/file" + "." + ext;
try {
File file = new File(fileName);
} catch(Exception e){
}
我为什么不能使用字段?
没有理由不能使用字段,即this.ext
。如果将调试点放在下面的行中,则会发现this.ext
未设置为"txt"
String fileName = "folder/file" + "." + this.ext;
如果您对调试器不满意,只需将以下行放在上面的行之前,就可以找到问题所在:
System.out.println("this.ext="+this.ext);