리소스:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteFileExample {
public static void main(String[] args) {
FileOutputStream fop = null;
파일 파일;
Content String = "추가된 내용";
try {
file = new File("test.txt");
fop = 새로운 FileOutputStream(파일);
// 파일이 없으면 만듭니다
if (!file.exists()) {
file.createNewFile();
}
// 바이너리로 변환 data
byte[] contentEnBytes = content.getBytes();
fop.write(EnBytes 내용);
fop.flush()를 호출합니다.
fop.close();
System.out.println("편집 완료!");
} catch (IOException e) {
e.printStackTrace();
} 마지막으로 {
시도 {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Please disable your ad blocker and refresh the window to use this website.