Advertisement
Josif_tepe

Untitled

Mar 23rd, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.io.*;
  2. public class Main {
  3.  
  4.     public static void main(String[] args) {
  5.         BufferedInputStream in  = null;
  6.         BufferedOutputStream out = null;
  7.         try {
  8.             in = new BufferedInputStream(new FileInputStream("in.txt"));
  9.             out = new BufferedOutputStream(new FileOutputStream("out.txt"));
  10.             for(int i = in.read(); i != 'O'; i = in.read()) {
  11.                 out.write(i);
  12.             }
  13.  
  14.             out.flush();
  15.         }
  16.         catch (IOException ex) {
  17.             System.out.println(ex);
  18.         }
  19.         finally {
  20.             try {
  21.                 if(in != null) {
  22.                     in.close();
  23.                 }
  24.                 if(out != null) {
  25.                     out.close();
  26.                 }
  27.             }
  28.             catch (IOException ex) {
  29.                 System.out.println(ex);
  30.             }
  31.         }
  32.  
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement