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){
    
   }
  }
 }
}

 

+ Recent posts