File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ package IO_example ;
2
+
3
+ import java .io .File ;
4
+ import java .io .IOException ;
5
+ import java .util .Scanner ;
6
+
7
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
8
+
9
+ public class JavaFileIOExample {
10
+
11
+ public static void main (String ... args ) throws IOException {
12
+ System .out .println ("Program started." );
13
+ readFileOnDisk ();
14
+ System .out .println ("Program finished." );
15
+ }
16
+
17
+ private static void readFileOnDisk () throws IOException {
18
+ String file = "src/test/resources/sample_input.txt" ;
19
+ Scanner scanner = new Scanner (new File (file ));
20
+ scanner .useDelimiter (" " );
21
+
22
+ assertTrue (scanner .hasNext ());
23
+ while (scanner .hasNext ()) {
24
+ System .out .println (scanner .next ());
25
+ }
26
+
27
+ scanner .close ();
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ cool test it is
You can’t perform that action at this time.
0 commit comments