利用字符流把文件内容输出到控制台

try{
            File fin=new File("hello.java");       
            BufferedReader in = new BufferedReader(new FileReader(fin));
            String s;
            while((s = in.readLine()) != null){
                System.out.println(s);          
            }
            in.close();
        }catch (FileNotFoundException e1){         
            e1.printStackTrace();
        }catch(IOException e2){   
            e2.printStackTrace();
        }

猜你喜欢

转载自1960370817.iteye.com/blog/2243926