public static void main(String[] args) {
String str = "中国人\r\n五千年的风和雨啊,藏了多少梦。";
try {
FileWriter fw = new FileWriter("D://2.txt");
fw.write(str);
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//在D盘创建了一个2.txt的文件,写入了str的内容,看看是不是你想问的
可以
File file = new File(path);
例如:
String path="G:\\fileParse\\test.txt";
可以的 先检测文件是否存在 不存在就创建