Advertisement
fensa08

#OS LAB1/2

Mar 23rd, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. #OS LAB1/2 made by Fensa08
  2.  
  3. import java.io.*;
  4. import java.util.ArrayList;
  5. import java.util.Collections;
  6.  
  7.  
  8. public class HW01_2 {
  9.     public static void main(String args[]) {
  10.  
  11.         FileInputStream in = null;
  12.         FileOutputStream out  = null;
  13.  
  14.         try{
  15.  
  16.             out = new FileOutputStream(new File("destinacija.txt"));
  17.             in = new FileInputStream(new File("izvor.txt"));
  18.             ArrayList<Character> txt = new ArrayList<>();
  19.             Character c;
  20.             while(in.available() > 0){
  21.                 c = (char) in.read();
  22.                 txt.add(c);
  23.             }
  24.             Collections.reverse(txt);
  25.             for(Character it: txt){
  26.                 System.out.println(it);
  27.                 out.write((int)it);
  28.             }
  29.  
  30.             out.close();
  31.             in.close();
  32.  
  33.         } catch (Exception e) {
  34.             System.out.println(e.getMessage());
  35.         }
  36.  
  37.     }
  38. }
  39.  
  40.  
  41.  
  42. /*
  43.  
  44. izvor.txt : Hello World !
  45. destinacija : ! dlroW olleH
  46.  
  47. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement