📄 readtextprices2.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 + -