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 流文件寫入完整寫法
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.