【发布时间】:2012-01-24 13:23:00
【问题描述】:
我正在使用下面的代码在 Java 中获取一个字符串以将其用作文件路径,但它有一个错误。我检查了地址是正确的,但我不知道确切的问题是什么?
String filename;
System.out.print("please write down the address of your specefic file:(please insert double '\\'instead of one '\')");
Scanner input=new Scanner(System.in);
filename=input.nextLine();
File n=new File(filename);
System.out.print(n.getPath());
compress(n);
【问题讨论】:
-
为了尽快获得更好的帮助,请尝试发布 SSCCE pscode.org/sscce.html
-
您需要比“它有错误”更具体。准确告诉我们正在发生的事情、时间与您期望发生的事情以及原因。
-
哪个错误,请添加示例?
-
address of your specefic file:(please insert double '\\'instead of one '\'这在 OS X 或 *nix 上效果不佳。 ;) (拼写为 'specific' 2 'i's, 1 'e'。)