Advertisement
Josif_tepe

Untitled

Mar 25th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import javax.annotation.processing.SupportedSourceVersion;
  2. import java.io.*;
  3. import java.util.logging.Filter;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args){
  8.         BufferedInputStream bis = null;
  9.         BufferedOutputStream bos = null;
  10.         try {
  11.             InputStream in = new FileInputStream("izvor.txt");
  12.              bis = new BufferedInputStream(in);
  13.             OutputStream out = new FileOutputStream("destinacija.txt");
  14.              bos = new BufferedOutputStream(out);
  15.  
  16.              BufferedReader bf = new BufferedReader(new InputStreamReader(bis));
  17.  
  18.              while(bf.ready()) {
  19.                  String s = bf.readLine();
  20.                  if(s.charAt(0) >= '0' && s.charAt(0) <= '9') {
  21.                      bos.write(s.getBytes());
  22.                      bos.write(10);
  23.                  }
  24.              }
  25.             bos.flush();
  26.  
  27.         }
  28.         catch (IOException ex ){
  29.  
  30.         }
  31.         finally {
  32.             try {
  33.                 if(bis != null)
  34.                   bis.close();
  35.                 if(bos != null)
  36.                  bos.close();
  37.  
  38.             }
  39.             catch (IOException e) {
  40.  
  41.             }
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement