public class FileInputStreamExam {
public static void main(String[] args) throws IOException {
String path = FileInputStreamExam.class.getResource("test.txt").getPath(); //[1]
System.out.println("이 파일의 경로 : " + path);
InputStream inputStream = new FileInputStream(path);
int readByte;
while ((readByte = inputStream.read())!=-1) {
System.out.println("읽은 바이트 : "+readByte);
System.out.println("읽은 문자 : " + (char) readByte); // 아스키코드값 형변환
}
inputStream.close();
}
}
[1] FileInputStreamExam.java 경로를 기준으로 파일 경로 생성
Systme.in 예제 (0) | 2020.06.14 |
---|---|
FileInputStream 클래스 read() 예제 (0) | 2020.06.14 |
FileOutStream write()메소드 예제 (0) | 2020.06.14 |
FileWriter 클래스 write() 메소드 예제 (0) | 2020.06.14 |
FileRead 클래스 read(char cbuf, offset, length) 예제 (0) | 2020.06.14 |
댓글 영역