Advertisement
Azazavr

Main (I/O) 1 of 2 (+ create file)

Mar 16th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.io.FileInputStream;
  2. import java.io.FileNotFoundException;
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         Test[] t1 = new Test[3];
  9.  
  10.         try (Scanner sc = new Scanner(new FileInputStream("C:\\azaza\\src\\Lesson_12_2\\workers.txt"), "WINDOWS-1251");
  11.         ) {
  12.             for (int i = 0; i < t1.length; i++) {
  13.                 String line = sc.nextLine();
  14.                 String[] tokens = line.split("\\|");
  15.                 t1[i] = new Test(tokens[0], tokens[1]);
  16.             }
  17.         } catch (FileNotFoundException e) {
  18.  
  19.         }
  20.         System.out.println(Arrays.toString(t1));
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement