JAVA- IO-InputStream

1073 단어 Inputstream
package test;

import java.io.FileInputStream;
import java.io.IOException;

public class InputStreamReview {

	/**
	 * 
	 *         :   InputStream    OutputStream 
	 * 
	 *   ,      
	 *
	 *eg:
	 * 
	 *1.         ,      
	 *2.          ,              ,            b  
	 *3.      ,read(byte[] b)              ,            b  
	 *                      ,    -1
	 *4.      
	 * 
	 */
	public static void main(String[] args) throws IOException {
		//         
		FileInputStream fis = new FileInputStream("D:/qq/aa.txt");
		//    byte    
		byte[] b = new byte[1024];
		int len = 0;
		//              ,            b 
		if((len=fis.read(b)) != -1){
			//         , String(byte[] bytes,int offset,int length)
			//                  byte   ,       String。	
			System.out.println(new String(b,0,len));
		}
		//     
		fis.close();

	}

}

좋은 웹페이지 즐겨찾기