【发布时间】:2017-12-02 11:24:22
【问题描述】:
我的代码发布在下面。假设我的用户名是 ThisPC,如果我这样写:“C:\Users\ThisPC\Desktop\Lista Produse.txt”它按预期工作,将我的文件保存在桌面上,但是当我尝试使用 %USERNAME% 时它是不工作。 (请记住,我使用的是 Java)提前感谢您的帮助。
try{
File f=new File("C:\\Users\\%USERNAME%\\Desktop\\List.txt");
Formatter x;
x=new Formatter("C:\\Users\\%USERNAME%\\Desktop\\List.txt");
while(enALL.hasMoreElements()){
x.format(""+enALL.nextElement());
x.format("\r\n");
}
x.close();
}
catch(FileNotFoundException e){
JFrame frame = new JFrame();
JOptionPane.showMessageDialog(frame, "Error.");
}
【问题讨论】:
-
我假设你正在使用 Java
标签: java