deyanmalinov

3. Copy Bytes

Apr 8th, 2020
221
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DPM;
  2. import java.io.FileInputStream;
  3. import java.io.FileOutputStream;
  4. import java.io.IOException;
  5. public class Main {
  6.     public static void main(String[] args) throws IOException {
  7.         String inputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
  8.                 "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
  9.                 "Files-and-Streams-Lab-Resources\\input.txt";
  10.         String outputPath = "D:\\Coding\\Java\\Softuni\\Java Advanced - January 2019" +
  11.                 "\\04. Java-Advanced-Fiels-and-Directories-Lab\\04. Java-Advanced-" +
  12.                 "Files-and-Streams-Lab-Resources\\output.txt";
  13.         FileReader inFile = new FileReader(inputPath);
  14.         FileWriter outFile = new FileWriter(outputPath);
  15.         int oneByte = 0;
  16.         while ((oneByte = inFile.read()) >= 0){
  17.             if (oneByte == 10 || oneByte == 32){
  18.                 outFile.write(oneByte);
  19.             }else {
  20.             String num = String.valueOf(oneByte);
  21.             for (int i = 0; i < num.length(); i++) {
  22.                 outFile.write(num.charAt(i));
  23.             }
  24.             }
  25.         }
  26.     }
  27. }
RAW Paste Data