fensa08

#OS LAB1/3

Mar 23rd, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. #OS LAB1/3 made by Fensa08
  2.  
  3. import java.io.*;
  4.  
  5.  
  6. public class HW01_3 {
  7.     public static void main(String args[]) throws IOException {
  8.  
  9.         BufferedReader in = null;
  10.         BufferedWriter out = null;
  11.  
  12.         StringBuilder sb  = new StringBuilder();
  13.  
  14.         try{
  15.  
  16.             in = new BufferedReader(new FileReader("izvor.txt"));
  17.             out = new BufferedWriter(new FileWriter("destinacija"));
  18.             String line;
  19.  
  20.             while((line = in.readLine()) != null){
  21.                 sb.append(line);
  22.             }
  23.             out.write(sb.reverse().toString());
  24.         } catch (Exception e) {
  25.             System.out.println(e.getMessage());
  26.         }finally{
  27.             if(in != null) in.close();
  28.             if(out != null) out.close();
  29.  
  30.         }
  31.  
  32.         System.out.println(sb);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment