Guest User

Untitled

a guest
Jun 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package com.javarush.task.task18.task1826;
  2.  
  3. /*
  4. Шифровка
  5. */
  6.  
  7. import java.io.FileInputStream;
  8. import java.io.FileOutputStream;
  9. import java.io.IOException;
  10.  
  11. public class Solution {
  12. public static void main(String[] args) {
  13. try {
  14. if (args[0].equals("-e")) {
  15. paramE(args);
  16. } else {
  17. paramD(args);
  18. }
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22.  
  23. }
  24.  
  25. public static void paramE(String[] args) throws IOException {
  26. FileInputStream inputStream = new FileInputStream(args[1]);
  27. FileOutputStream outputStream = new FileOutputStream(args[2]);
  28. while (inputStream.available() > 0) {
  29. outputStream.write(inputStream.read() + 1);
  30. }
  31. inputStream.close();
  32. outputStream.close();
  33.  
  34.  
  35. }
  36.  
  37. public static void paramD(String[] args) throws IOException {
  38. FileInputStream inputStream = new FileInputStream(args[1]);
  39. FileOutputStream outputStream = new FileOutputStream(args[2]);
  40. while (inputStream.available() > 0) {
  41. outputStream.write(inputStream.read() - 1);
  42. }
  43. inputStream.close();
  44. outputStream.close();
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment