I says that I have an infinte loop, but when I run the code I get the wanted output
package com.codegym.task.task19.task1908;
/*
Picking out numbers
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
String s= null;
public static boolean isInteger(String s){
try{
Integer.parseInt(s);
return true;
}catch (Exception e){
return false;
}
}
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileReader fileReader = new FileReader(reader.readLine());
FileWriter fileWriter = new FileWriter(reader.readLine());
Scanner scaner = new Scanner(fileReader);
scaner.useDelimiter("\\s");
while (scaner.hasNext()){
String data = scaner.next();
if (isInteger(data)){
fileWriter.write(data);
}
}
reader.close();
fileReader.close();
fileWriter.close();
}
}