deyanmalinov

4. Extract Integers

Apr 8th, 2020
183
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DPM;
  2.  
  3. import java.io.*;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) throws IOException {
  8.         String inputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
  9.                 "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
  10.                 "Files-and-Streams-Lab-Resources\\input.txt";
  11.         String outputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
  12.                 "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
  13.                 "Files-and-Streams-Lab-Resources\\output.txt";
  14.         Scanner scan = new Scanner(new FileInputStream(inputPath));
  15.         FileWriter outFile = new FileWriter(outputPath);
  16.         while (scan.hasNext()){
  17.             if (scan.hasNextInt()) {
  18.                 System.out.println(scan.nextInt());
  19.             }
  20.             scan.next();
  21.         }
  22.     }
  23. }
RAW Paste Data