Advertisement
Tsuki11

Untitled

Jun 6th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.io.*;
  2. import java.nio.file.Files;
  3.  
  4. public class L3_CopyBytes {
  5. public static void main(String[] args) throws IOException {
  6. // BufferedReader in = new BufferedReader(new FileReader("inputLab.txt"));
  7.  
  8. File file = new File("inputLab.txt");
  9.  
  10. byte[] bytes = Files.readAllBytes(file.toPath());
  11.  
  12. Writer writer = new FileWriter("outputBytes.txt");
  13. OutputStream result = new FileOutputStream("outBytes1.txt");
  14. for (byte b : bytes) {
  15. String outSymbol = String.valueOf(b);
  16.  
  17. if (b == 32) {
  18. outSymbol = " ";
  19. result.write(b);
  20.  
  21. } else if (b == 10) {
  22. outSymbol = System.lineSeparator();
  23. result.write(b);
  24. }else{
  25. for (int i = 0; i < outSymbol.length(); i++) {
  26. result.write(outSymbol.charAt(i));
  27. }
  28. }
  29.  
  30. writer.write(outSymbol);
  31.  
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement