【发布时间】:2016-07-10 03:20:46
【问题描述】:
我有一个包含以下代码行的程序:
//String s = fileName;
File location = new File(s);
然后我有
//String contents = whatIWantToPrint;
OutputStream print = new FileOutputStream(location);
print.write(contents.getBytes());
print.close();
告诉程序将字符串内容打印到文件 s。但是,该文件出现在程序所在的文件夹中,而不是程序所在的目录中。例如,如果程序在个人桌面上,我希望它在他们的桌面上制作文件。
我在终端中使用以下行将程序制作为 jar 文件(mac):
jar -cvmf manifest.txt Generate.jar *.class
【问题讨论】:
标签: java file path outputstream