import java.io.*; public class CheckFile { private File f ;
private BufferedReader bdr;
private char[] c =new char[1024];
private PrintWriter pw ; CheckFile() { try { f=new File("D:\\myRead","myText.txt"); }catch (Exception e) { e.getMessage();
} if(f.exists()) { System.out.print("文件存在"+"\n"); try { bdr=new BufferedReader(new FileReader(f)); while ((bdr.read(c,0,c.length))!=-1) { pw=new PrintWriter(System.out); pw.print(c); pw.flush();
} pw.close(); }catch (IOException e) { System.out.println(e.getMessage());
} }else { System.out.println("文件夹没有文件,呵呵。");
} } public static void main (String [] args) { new CheckFile(); }
}