SHARE
TWEET

Untitled

a guest Feb 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.javarush.task.task19.task1923;
  2.  
  3. /*
  4. Слова с цифрами
  5. */
  6.  
  7. import java.io.*;
  8. import java.util.regex.Matcher;
  9. import java.util.regex.Pattern;
  10.  
  11. public class Solution {
  12.     public static void main(String[] args) throws IOException {
  13.  
  14.         String fn1 = args[0];
  15.         String fn2 = args[1];
  16.         FileReader fr = new FileReader(fn1);
  17.         FileWriter fw = new FileWriter(fn2);
  18.         BufferedReader br = new BufferedReader(fr);
  19.  
  20.         while (br.ready()) {
  21.             String[] str = br.readLine().split(" ");
  22.             for (String word : str) {
  23.                 Pattern p = Pattern.compile( ".*\\d.*");
  24.                 Matcher m = p.matcher(word);
  25.                 while (m.find()) {
  26.                     fw.write(word + " ");
  27.                 }
  28.             }
  29.         }
  30.         fr.close();
  31.         fw.close();
  32.         br.close();
  33.  
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top