您的位置:首页 > 其它

读取文件中的内容将其显示出来

2009-11-21 16:37 218 查看
//读取文件中的内容将其显示出来
public class ReadFile{
public static void main(String[] args) {

int b;
byte tom[] = new byte[1000];
File file = new File("c://system.xml");
try {
FileInputStream f = new FileInputStream(file);

b = f.read(tom,0,280);
while(b!=-1){
//StringBuffer str = new StringBuffer();
String str = new String(tom,0,b);
System.out.println(str);
break;
}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐