Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alekseytimoshchenko/961861276fa0c5f6be771ead79be6b14 to your computer and use it in GitHub Desktop.
Save alekseytimoshchenko/961861276fa0c5f6be771ead79be6b14 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedReader reader = new BufferedReader(new FileReader(br.readLine()));
BufferedWriter writer = new BufferedWriter(new FileWriter(br.readLine(), true));
String[] str;
String line;
while ((line = reader.readLine()) != null){
str = line.split(" ");
for (String tmp : str){
if (isNumeric(tmp)){
String strToWrite = tmp + " ";
writer.write(strToWrite);
}
}
}
br.close();
reader.close();
writer.close();
}
public static boolean isNumeric(String str)
{
try
{
double d = Double.parseDouble(str);
}
catch(NumberFormatException nfe)
{
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment