Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class HW01_2 {
- public static void main(String[] args) throws IOException {
- FileInputStream input = null;
- FileOutputStream output = null;
- try {
- input = new FileInputStream("izvor.txt");
- output = new FileOutputStream("destinacija.txt");
- int key;
- StringBuilder sb = new StringBuilder();
- while ((key = input.read()) != -1) {
- sb.append((char) key);
- }
- for (byte b : sb.reverse().toString().getBytes()) {
- output.write(b);
- }
- } catch (FileNotFoundException e) {
- } finally {
- try {
- input.close();
- output.close();
- } catch (IOException e) {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment