Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package pl.borowa.springtest.domain;
  2.  
  3. import java.io.*;
  4. import java.util.Scanner;
  5. import java.util.Set;
  6. import java.util.TreeSet;
  7.  
  8. public class jakasJava {
  9.     public static void main(String[] args) {
  10.         Set<Integer> liczby = new TreeSet<>();
  11.         try(Scanner file = new Scanner(new File("C:\\Users\\Borowa\\IdeaProjects\\springtest_annotation_config\\src\\main\\java\\pl\\borowa\\springtest\\domain\\liczby.txt"))) {
  12.             while (file.hasNextLine()) {
  13.                 liczby.add(Integer.parseInt(file.nextLine()));
  14.             }
  15.         } catch (FileNotFoundException e) {
  16.             e.printStackTrace();
  17.         }
  18.  
  19.         try (PrintWriter save = new PrintWriter("C:\\Users\\Borowa\\IdeaProjects\\springtest_annotation_config\\src\\main\\java\\pl\\borowa\\springtest\\domain\\liczby_save.txt")) {
  20.             liczby.forEach(save::println);
  21.         } catch (FileNotFoundException e) {
  22.             e.printStackTrace();
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement