⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readfiletestindir.java

📁 java练习程序
💻 JAVA
字号:
import java.io.*;
import java.awt.*;
import java.awt.event.*;

class ReadFileTestInDir {
    static Frame f;
    public static void main(String args[]) {
        int b, j = 10;
        TextArea text;
        byte tom[] = new byte[2500];
        f = new Frame();
        f.setSize(100, 100);
        text = new TextArea(30, 60);
        f.setVisible(true);
        f.add(text);
        f.pack();
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                f.setVisible(false);
                System.exit(0);
            }
        });
        try {
            File f = new File("E:\\信息系统开发技术\\", "Testfile.txt");
            FileInputStream readfile = new FileInputStream(f);
            while ((b = readfile.read(tom, 0, j)) != -1) {
                String s = new String(tom, 0, j);
                System.out.println(s);
                text.append(s + '\n');
            }
            readfile.close();
        } catch (IOException e) {
            System.out.println("Pile read Error ");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -