Advertisement
Guest User

Vtora Zadacha

a guest
Mar 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.ArrayList;
  3.  
  4. public class RUnner {
  5. public static void main(String[] args) throws IOException {
  6. File izvor = new File("C:\\Users\\David\\Desktop\\test\\izvor.txt");
  7. File destinacija = new File("C:\\Users\\David\\Desktop\\test\\destinacija.txt");
  8.  
  9. InputStream chitach = new FileInputStream(izvor);
  10. OutputStream zapishuvach = new FileOutputStream(destinacija);
  11. BufferedReader chitachDestinacija = new BufferedReader(new FileReader(destinacija));
  12.  
  13. ArrayList<Integer> lista = new ArrayList<>();
  14.  
  15. int bajt = 0;
  16.  
  17. while ((bajt=chitach.read())!= -1){
  18. lista.add(bajt);
  19. }
  20.  
  21. for (int i = lista.size() -1; i >= 0; i--) {
  22. zapishuvach.write(lista.get(i));
  23. }
  24.  
  25. chitach.close();
  26. zapishuvach.flush();
  27. zapishuvach.close();
  28.  
  29. String celosenText = "";
  30.  
  31. while ((celosenText=chitachDestinacija.readLine())!=null){
  32. System.out.println(celosenText);
  33. }
  34. chitachDestinacija.close();
  35. }
  36. }
  37.  
  38.  
  39. =========================================================================================================
  40.  
  41. import java.io.*;
  42. import java.util.ArrayList;
  43.  
  44. public class RUnner {
  45. public static void main(String[] args) throws IOException {
  46. File izvor = new File("C:\\Users\\David\\Desktop\\test\\izvor.txt");
  47. File destinacija = new File("C:\\Users\\David\\Desktop\\test\\destinacija.txt");
  48.  
  49. InputStream chitach = new FileInputStream(izvor);
  50. OutputStream zapishuvach = new FileOutputStream(destinacija);
  51.  
  52. ArrayList<Integer> lista = new ArrayList<>();
  53.  
  54. int bajt = 0;
  55.  
  56. while ((bajt=chitach.read())!= -1){
  57. lista.add(bajt);
  58. }
  59.  
  60. for (int i = lista.size() -1; i >= 0; i--) {
  61. zapishuvach.write(lista.get(i));
  62. }
  63.  
  64. chitach.close();
  65. zapishuvach.flush();
  66. zapishuvach.close();
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement