import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class FileInputStreamEx {
public static void main(String[] args) {
File f = new File("C:/noirjo/work1/alter_jari/src/month7_day9/FileTest.java"); //읽어들일 파일 경로....
FileInputStream fis = null;
byte[] bytes = new byte[256];
int _byte=-1;
try{
fis = new FileInputStream(f);
// while문으로 읽을때...
// while((fis.read(bytes)) != -1){
// System.out.println(new String(bytes));
// }
//1바이트로 다 읽어 들인다.
while((_byte = fis.read()) != -1){
System.out.print((char)_byte);
}
} catch(Exception e){
e.printStackTrace();
} finally{
try{
if(fis!=null) fis.close();
} catch (IOException e){
}
}
}
}
'2020년도 이전 > 입출력' 카테고리의 다른 글
파일 읽고, 쓰기 - 자바 파일 복사 (0) | 2013.07.09 |
---|---|
경로에 있는 Directory와 파일의 바이트 크기 출력 (0) | 2013.07.09 |
알파벳 입력하면 아스키코드 출력 (0) | 2013.07.09 |