String word = "IO流的写法";
String uploadPath = "upload";
FileOutputStream fop = null;
File file;
try {
file = new File(uploadPath, "Hellow.txt");
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
if (!file.exists()) {
file.createNewFile();
}
fop = new FileOutputStream(file);
fop.write(word.getBytes());
fop.flush();
fop.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
IO 流文件写入完整写法
版权声明:本文为qq_40965204原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。