Advertisement
krstevskim

OS_L1_2

Mar 19th, 2019
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.ArrayList;
  3. import java.util.Collections;
  4. import java.util.Scanner;
  5.  
  6. public class HW01_2 {
  7.     public static void main(String args[]) {
  8.             File fout;
  9.             File f;
  10.             FileInputStream in=null;
  11.             OutputStream out=null;
  12.             try{
  13.                 f=new File("G:\\imenik\\izvor.txt");
  14.                 fout=new File("G:\\imenik\\destination.txt");
  15.                 in=new FileInputStream(f);
  16.                 out=new FileOutputStream(fout);
  17.                 ArrayList<Character> tekst=new ArrayList<>();
  18.                 Character c;
  19.                 while(in.available()>0){
  20.                     c=(char)in.read();
  21.                     tekst.add(c);
  22.                 }
  23.                 Collections.reverse(tekst);
  24.                 for(Character i:tekst) {
  25.                     out.write((int) i);
  26.                 }
  27.                 out.flush();
  28.                 out.close();
  29.                 in.close();
  30.             }
  31.             catch (Exception e){
  32.                 System.out.println(e.getMessage());
  33.             }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement