-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScannerEx.java
More file actions
38 lines (28 loc) · 843 Bytes
/
Copy pathScannerEx.java
File metadata and controls
38 lines (28 loc) · 843 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
package com.javaex.io.charstream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ScannerEx {
static String dirName = "D:\\javastudy\\files\\";
static String filename = dirName + "thieves.txt";
public static void main(String[] args) {
File file = new File(filename);
try {
Scanner scanner = new Scanner(file);
String name;
float height;
float weight;
while(scanner.hasNextLine()) {
name = scanner.next();
height = scanner.nextFloat();
weight = scanner.nextFloat();
System.out.printf("%s, 키:%f, 체중:%f%n", name, height, weight);
scanner.nextLine();
}
scanner.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}