PrintWriter를 통해 data.txt파일에 안녕하세요. PrintWriter입니다.라고 적어보세요 라고 하셨는데요...
안녕하세요. PrintWriter입니다.
적어보세요가 저장해보라는 뜻인지요
PrintWriter는 대상파일의 내용을 출력 하는걸로 아는데요
조언 부탁드리겠습니다. 감사합니다..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import java.io.*; public class CharIOExam{ public static void main(String[]args){ PrintWriter hello = null; try{ hello = new PrintWriter(new FileWriter("data.txt")); String hi = null; while((hi = hello.println()) !=null){ hello.Println(hi); } }catch(Exception e){ e.printStackTrace(); }finally { hello.close(); } System.out.println("안녕하세요. PrintWriter입니다."); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import java.io.*; public class CharIOExam{ public static void main(String[]args){ PrintWriter hello = null; try{ hello = new PrintWriter(new FileWriter("data.txt")); String hi = null; while((hi = hello.println()) !=null){ hello.Println(hi); } }catch(Exception e){ e.printStackTrace(); }finally { hello.close(); } System.out.println("안녕하세요. PrintWriter입니다."); } }
네. 저장하라는 의미입니다. PrintWriter는 대상 파일의 내용을 출력하는게 아니라, 대상 파일에 텍스트를 써 줍니다.
답변 감사합니다..해결되었습니다.꾸벅~!