Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task19.task1923;
- /*
- Слова с цифрами
- */
- import java.io.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Solution {
- public static void main(String[] args) throws IOException {
- String fn1 = args[0];
- String fn2 = args[1];
- FileReader fr = new FileReader(fn1);
- FileWriter fw = new FileWriter(fn2);
- BufferedReader br = new BufferedReader(fr);
- while (br.ready()) {
- String[] str = br.readLine().split(" ");
- for (String word : str) {
- Pattern p = Pattern.compile( ".*\\d.*");
- Matcher m = p.matcher(word);
- while (m.find()) {
- fw.write(word + " ");
- }
- }
- }
- fr.close();
- fw.close();
- br.close();
- }
- }
Add Comment
Please, Sign In to add comment