用FileOutputStream直接拿文件再输出字符串不就行了
这...百度一下io流
String str = "传智播客";
String dirPath = "D://test/";
File dir = new File(dirPath);
if (!dir.exists()) {
dir.mkdirs();
}
File file = new File(dirPath+"itcast.txt");
try {
FileWriter writer = new FileWriter(file);
writer.write(str);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}