import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; /** * @author mugrammer * */ public class FileReader { /** * @param args */ public static void main(String[] args) { String path = args[0]; if(path == null){ return; } File fr = new File(path); String line; try { BufferedReader inFile = new BufferedReader(new InputStreamReader(new FileInputStream(fr), "utf-8")); while ((line = inFile.readLine()) != null) { System.out.println(line); } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
반응형
'Java' 카테고리의 다른 글
[Java] SimpleDateFormat (0) | 2015.04.02 |
---|---|
Try Catch Finally 동작순서 (0) | 2014.12.31 |
Calendar 특정일자로 지정하기 (0) | 2013.10.15 |
Java Compiler (0) | 2013.03.07 |
eclipse 한글 패치 (0) | 2013.01.19 |