import java.io.*;
public class FileInputStreamTest2 {
	public static void main( String[] args ) {
		byte[] b = new byte[10];
		byte[] temp = new byte[10];
		int inputValue = 0;
		FileInputStream file = null;
		try {
			// "data.txt" File과 InputStream 형성
			file = new FileInputStream( "C:\\java_pm\\study\\d_day01\\test\\read.txt" );
			// byte[]의 크기만큼 데이타를 읽어 들임.
			inputValue = file.read( b );
			System.out.println( "inputValue = " + inputValue );
			// 배열을 이용해 문자열 생성
			System.out.println( "String : " + new String( b ));
			// byte[]의 크기만큼 데이타를 읽어 들임
			inputValue = file.read( temp, 0, 3 );
			System.out.println( "inputValue = " + inputValue );
			System.out.println( "String : " + new String( temp ));
			// File과 연결된 입력 스트림을 닫음
			file.close();
			}catch( Exception e ) {
			System.out.println( e.toString() );
		}
	}
}
'새로워지기 > 서른의 생활코딩' 카테고리의 다른 글
| ex10) java.io.* (0) | 2012.03.06 | 
|---|---|
| ex9) java.io.* (0) | 2012.03.06 | 
| ex7) java.io.* (0) | 2012.03.06 | 
| ex6) java.io.* (0) | 2012.03.06 | 
| ex5) java.io.* (0) | 2012.03.06 | 
댓글