打开文件
用代码怎样实现在屏幕上显示打开文件的内容呀?不一定是文本文件!
char[] buf=new char[1024];
File f =new File("file.txt");
FileRaeder in =new FileReader (f);
int len=in.read(buf);
System.out.println(new String(buf,0,len));
或者
byte[] buf=new byte[1024];
File f =new File("file.txt");
FileInputStream in =new FileInputStream (f);
int len=in.read(buf);
System.out.println(new String(buf,0,len));
也行吧