今天爱分享给大家带来读取一个文件在控制台打印出来【面试题详解】,希望能够帮助到大家。
File file = new File("E:\\JRadioButtonDemo.java");
long file_length= file.length();
try {
//输入流
FileInputStream input = new FileInputStream(file);
byte b_data [] = new byte[(int)file_length];
input.read(b_data);
System.out.println(new String(b_data));
input.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
原文链接:https://blog.itblood.com/3604.html,转载请注明出处。

