File With Line Numbers Inserted Java

[Solved] File With Line Numbers Inserted Java | Scala - Code Explorer | yomemimo.com
Question : file with line numbers inserted java

Answered by : cute-cod-nimw4a2tzmwf

import java.io.*;
class FileCopy
{ public static void main(String[] args) { try { File fileIn = new File("Assign4.txt"); File fileOut = new File("target.txt"); FileInputStream streamIn = new FileInputStream(fileIn); FileOutputStream streamOut = new FileOutputStream(fileOut); int c; while ((c = streamIn.read()) != -1) { streamOut.write(c); } streamIn.close(); streamOut.close(); } catch (FileNotFoundException e) { System.err.println("FileCopy: " + e); } catch (IOException e) { System.err.println("FileCopy: " + e); } }
}

Source : https://stackoverflow.com/questions/17016242/reading-writing-files-in-java-and-adding-line-numbers?rq=1 | Last Update : Thu, 19 Mar 20

Answers related to file with line numbers inserted java

Code Explorer Popular Question For Scala