example8_1.java
来自「书中的例题」· Java 代码 · 共 23 行
JAVA
23 行
/* 读取文件 */
import java.io.*;
import javax.swing.*;
class Example8_1
{ public static void main( String args[ ])
{ byte buffer[ ] = new byte[2056];
String str;
try {
File file=new File("e:/jtest/test.dat");
FileInputStream fileInput = new FileInputStream(file);
int bytes = fileInput.read( buffer, 0, 2056 );
str = new String( buffer, 0, bytes );
}
catch(Exception e)
{
str= e.toString();
}
JOptionPane.showMessageDialog(null,str);
System.exit(0); //退出程序
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?