-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringTokenizerEx.java
More file actions
40 lines (32 loc) · 988 Bytes
/
Copy pathStringTokenizerEx.java
File metadata and controls
40 lines (32 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.javaex.io.charstream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.StringTokenizer;
public class StringTokenizerEx {
static String dirName = "D:\\javastudy\\files\\";
static String filename = dirName + "thieves.txt";
public static void main(String[] args) {
// 스트림을 열어봅시다
try {
Reader freader = new FileReader(filename);
BufferedReader br = new BufferedReader(freader);
String thief;
while((thief = br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(thief, " ");
while(st.hasMoreTokens()) {
String token = st.nextToken();
System.out.print(token + " ");
}
System.out.println();
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}