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

📄 readtextprices2.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import java.io.*;
import java.util.*;   // needed for StringTokenizer
public class ReadTextPrices2
{
  public static void main(String[] args)
    throws java.io.IOException
  {
    String fileName = "prices.txt";    
    int i;
    double price;
    String inLine, desc;
    StringTokenizer st;

       // set up a bufered input stream - notice the single statement used
    BufferedReader br = new BufferedReader(new FileReader(fileName));

      // read and display three lines
    for (i = 0; i < 3; i++)
    {
      inLine = br.readLine();    
      st = new StringTokenizer(inLine);
      desc = st.nextToken();
      price = Double.parseDouble(st.nextToken());      
      System.out.println("Description: " + desc + '\t'
                        + "Price: " + price);
    } 

    br.close(); 
 }
}

⌨️ 快捷键说明

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