반응형 파일 내용 지우기1 JAVA - 자바 파일 삭제하기 / 파일 이름, 경로 바꾸기 (delete() / renameTo()) 1. 파일 내용 삭제 파일은 그대로 두고 파일의 내부 내용만 삭제하는 방법입니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import java.io.*; public class FileTest { public static void fileDataClear(String filePath) { try { new FileWriter(filePath).close(); } catch (IOException e) { System.out.println(e); } } public static void main(String[] args) { String filePath = "/path/path/filename.txt"; fileDataClear(fileP.. 2022. 9. 22. 이전 1 다음 728x90 반응형