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

📄 printlines.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
import java.io.*;// This class reads lines from standard input (System.in) and// prints each line along with its line number.public class PrintLines extends Object{  public static void main(String[] args)  {    // Set up a line number input filter to count the line numbers    LineNumberReader lineCounter = new LineNumberReader( new InputStreamReader( System.in ) );    String nextLine = null;    System.out.println( "Type any text and press return. Type 'exit' to quit the program." );    try    {      // Keep going until exit is typed      while ( (nextLine = lineCounter.readLine()).indexOf( "exit") == -1 )      {        // If readLine returns null, we've hit the end of the file        if (nextLine == null) break;        // Print out the current line number followed by the line        System.out.print(lineCounter.getLineNumber());        System.out.print(": ");        System.out.println(nextLine);      }    }    catch (Exception done)    {      done.printStackTrace();    }  }}

⌨️ 快捷键说明

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