package jp03.part0415.study;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileInputStreamTest01 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
FileInputStream fis = null;
int readCount = 0;
try {
fis = new FileInputStream(args[0]);
while(true){
int i = fis.read();
if(i == -1){
break;
}
char c = (char)i;
System.out.print(c);
readCount++;
}
fis.close();
} catch (FileNotFoundException e) {
// TODO: handle exception
e.printStackTrace();
} catch (IOException e1){
e1.printStackTrace();
} finally{
System.out.println("\n\n=======> read 횟수 readCount : " + readCount);
}
}
}
[원본 : test.txt]
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
//한글이 있을 경우는????
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
[결과]
'프로그램 > Java & Jsp' 카테고리의 다른 글
Java IO - (6) -> [BufferedReader] (0) | 2008.08.20 |
---|---|
Java IO - (5) -> [FileReader] (0) | 2008.08.20 |
Java IO - (3) -> [Writer] (0) | 2008.08.20 |
Java IO - (2) -> [Reader] (0) | 2008.08.20 |
Java IO - (1) -> [InputStream] (0) | 2008.08.20 |