Niloy007

FinalSampleProb2

Dec 14th, 2019
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2.  
  3. public class SecondSolution {
  4.     public static void main(String[] args) {
  5.  
  6.         String absPath = "src/SampleSolution/A.txt";
  7.         String copypath = "src/SampleSolution/B.txt";
  8.  
  9.         FileReader fileReader;
  10.         FileWriter fileWriter;
  11.         BufferedReader bufferedReader;
  12.         BufferedWriter bufferedWriter;
  13.         try {
  14.             File file2 = new File(absPath);
  15.             File file = new File(copypath);
  16.  
  17.             boolean fvar = file.createNewFile();
  18.             boolean fvar2 = file2.createNewFile();
  19.  
  20.             fileReader = new FileReader(absPath);
  21.             bufferedReader = new BufferedReader(fileReader);
  22.             fileWriter = new FileWriter(copypath, true);
  23.             bufferedWriter = new BufferedWriter(fileWriter);
  24.  
  25.             String a;
  26.  
  27.             while((a = bufferedReader.readLine()) != null) {
  28.                 bufferedWriter.write(a);
  29.                 bufferedWriter.newLine();
  30.             }
  31.  
  32.             bufferedWriter.close();
  33.         } catch (IOException e) {
  34.  
  35.         }
  36.     }
  37. }
RAW Paste Data