deyanmalinov

2. Write to File

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