package com.codegym.task.task19.task1923;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedWriter;
/*
Words with numbers
*/
public class Solution {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new FileReader(args[0]));
String regex = ".*\\d+.*";
FileWriter fw = new FileWriter(args[1]);
StringBuilder sb = new StringBuilder();
while(br.ready())
{
sb.append((char)br.read());
}
String[] elements = sb.toString().split(" ");
StringBuilder outsb = new StringBuilder();
for(String element : elements)
{
if(element.matches(regex))
outsb.append(element + " ");
}
String out = outsb.toString();
fw.write(out.trim());
fw.close();
br.close();
}
}
package com.codegym.task.task19.task1923;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedWriter;
/*
Words with numbers
*/
public class Solution {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new FileReader(args[0]));
String regex = ".*\\d+.*";
FileWriter fw = new FileWriter(args[1]);
StringBuilder sb = new StringBuilder();
while(br.ready())
{
sb.append((char)br.read());
}
String[] elements = sb.toString().split(" ");
StringBuilder outsb = new StringBuilder();
for(String element : elements)
{
if(element.matches(regex))
outsb.append(element + " ");
}
String out = outsb.toString();
fw.write(out.trim());
fw.close();
br.close();
}
}