file with line numbers inserted java

Solutions on MaxInterview for file with line numbers inserted java by the best coders in the world

showing results for - "file with line numbers inserted java"
Sophia
16 Jul 2018
1import java.io.*;
2
3class FileCopy
4{
5   public static void main(String[] args) 
6   {
7      try 
8      {
9         File fileIn  = new File("Assign4.txt");
10         File fileOut = new File("target.txt");
11
12         FileInputStream streamIn   = new FileInputStream(fileIn);
13         FileOutputStream streamOut = new FileOutputStream(fileOut);
14
15         int c;
16         while ((c = streamIn.read()) != -1) 
17         {
18            streamOut.write(c);
19         }
20
21         streamIn.close();
22         streamOut.close();
23      }
24      catch (FileNotFoundException e) 
25      {
26         System.err.println("FileCopy: " + e);
27      } 
28      catch (IOException e) 
29      {
30         System.err.println("FileCopy: " + e);
31      }
32   }
33}