Latkoski

OS_Lab01_zad02_a

Feb 20th, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package zad2;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.InputStreamReader;
  8. import java.io.OutputStreamWriter;
  9. import java.io.FileNotFoundException;
  10. import java.util.ArrayList;
  11.  
  12. public class Lab01_zad02 {
  13.     public static void main(String[] args) throws IOException {
  14.  
  15.         File source = null;
  16.         File destination = null;
  17.         source = new File("izvor.txt");
  18.         destination = new File("destinacija.txt");
  19.         FileInputStream fis = new FileInputStream(source);
  20.         FileOutputStream fos = new FileOutputStream(destination);
  21.         InputStreamReader in = new InputStreamReader(fis);
  22.         OutputStreamWriter out = new OutputStreamWriter(fos);
  23.  
  24.         try {
  25.             char[] array = new char[100];
  26.             in.read(array);
  27.             StringBuilder sb = new StringBuilder();
  28.             for (int i = array.length - 1; i >= 0; i--) {
  29.                 sb.append(array[i]);
  30.             }
  31.             String content = sb.toString();
  32.             out.write(content);
  33.         } finally {
  34.             in.close();
  35.             out.close();
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment