这是我的Java代码。
File file = new File(path);
StringWriter sw = new StringWriter();
//Do something.
out.println(sw.toString()); //Works fine; prints.
try {
FileUtils.writeStringToFile(file, sw.toString(), "UTF-8");
} catch (IOException e) {
throw new RuntimeException( e );
}
我还没有创建文件,也没有在执行后创建它。我怎样才能做到这一点?