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

📄 textfileinputdemo.java

📁 java编程代码
💻 JAVA
字号:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

public class TextFileInputDemo
{
    public static void main(String[] args)
    {
       try
       {
           BufferedReader inputStream = 
              new BufferedReader(new FileReader("morestuff2.txt"));

           String line = inputStream.readLine( );
           System.out.println(
                            "The first line read from the file is:");
           System.out.println(line);
        
           line = inputStream.readLine( );
           System.out.println(
                           "The second line read from the file is:");
           System.out.println(line); 
           inputStream.close( );
       }
       catch(FileNotFoundException e)
       {
           System.out.println("File morestuff2.txt was not found");
           System.out.println("or could not be opened.");
       }
       catch(IOException e)
       {
           System.out.println("Error reading from morestuff2.txt.");
       }
    }
}

⌨️ 快捷键说明

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