2019.01.18 파일 읽어오기
2019. 1. 18. 15:02ㆍJAVA
#1 파일 읽어오기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Hello { public static void main(String[] args) { File file = new File("input.txt"); try { Scanner sc = new Scanner(file); while(sc.hasNextInt()) { System.out.println(sc.nextInt()*100); } sc.close(); } catch (FileNotFoundException e) { System.out.println("파일을 읽어오는 중 오류 발생"); } }//main() } | cs |
-> 여기서 input.txt 파일을 생성해줘야한다.
'JAVA' 카테고리의 다른 글
2019.01.21 예제) 데이터 입력 및 데이터 검색(Map,List) (0) | 2019.01.22 |
---|---|
2019.01.21 배치처리 (0) | 2019.01.22 |
2019.01.15 JavaFX에서 키보드 동작(액션) (1) | 2019.01.15 |
2019.01.14 JavaFx 활용하기 (0) | 2019.01.14 |
2018.01.11 멀티 스레드의 활용 (0) | 2019.01.11 |