반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- html
- postorder
- classification
- 웹 용어
- discrete_scatter
- bccard
- inorder
- C언어
- web 사진
- 결합전문기관
- 자료구조
- pycharm
- 대이터
- java역사
- web
- KNeighborsClassifier
- Keras
- web 개발
- CES 2O21 참가
- tensorflow
- CES 2O21 참여
- cudnn
- web 용어
- mglearn
- vscode
- 재귀함수
- paragraph
- 데이터전문기관
- broscoding
- 머신러닝
Archives
- Today
- Total
bro's coding
java.BufferedReader 본문
반응형
package step1;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TestInput1 {
public static void main(String[] args) {
String path = "C:\\4. kosta215\\iotest\\friend.txt";
// System.out.println(new File(path).isFile());
try {
// 입력받는 노드 문자스트림 : FileReater
FileReader fr = new FileReader(path);
// 입력 프로세스 문자스트림 : BufferedReader
BufferedReader br = new BufferedReader(fr);
// System.out.println(br.readLine());
// System.out.println(br.readLine());
// System.out.println(br.readLine());
// System.out.println(br.readLine());// 더 이상 읽을 문자열 라인이 없으면 null 반환
String s = "";
while (s != null) {
s = br.readLine();
System.out.println(s);
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package step1;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
// TestInput1의 입력 방식을 다른 방법으로 해본다( ready()를 이용)
public class TestInput2 {
public static void main(String[] args) {
String path = "C:\\4. kosta215\\iotest\\friend.txt";
// System.out.println(new File(path).isFile());
try {
// 입력받는 노드 문자스트림 : FileReater
FileReader fr = new FileReader(path);
// 입력 프로세스 문자스트림 : BufferedReader
BufferedReader br = new BufferedReader(fr);
// System.out.println(br.readLine());
// System.out.println(br.readLine());
// System.out.println(br.readLine());
// System.out.println(br.readLine());// 더 이상 읽을 문자열 라인이 없으면 null 반환
while (br.ready()) {// 문자열이 있으면 true
System.out.println(br.readLine());
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
반응형
'[IT] > java' 카테고리의 다른 글
java.SerialVersionUID (0) | 2021.03.15 |
---|---|
java.byte파일 컨트롤 (0) | 2021.03.15 |
java.문자열 파일 컨트롤 (0) | 2021.03.15 |
java.file입력/출력 (0) | 2021.03.15 |
java.Scanner(입력) (0) | 2021.03.12 |
java.Stream.NodeStream/ProcessingStream (0) | 2021.03.12 |
java.IO.File/Directory (0) | 2021.03.12 |
java.switch (0) | 2021.03.11 |
Comments