Hey, I have an assignment to :write a program that reads a file and writes a copy of the file to another file with line numbers inserted. I am not sure what to do at the end of the code at the "for(int i =0; i < lines.length; i++)" part. what do I need to do for the "lines" part and how do I add the line numbers?
Thanks
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Question43
{
public static void main(String[] args) throws IOException
{
Scanner fileIn = new Scanner(new File("Chapter 11Assign43.txt") );
FileWriter fileOut = new FileWriter("FileOut.txt");
PrintWriter output = new PrintWriter(fileOut);
String []array = new String[10];
int indx = 0;
while(fileIn.hasNext( ) )
{
array[indx] = fileIn.nextLine( );
}
fileIn.close();
int num = 1;
for(int i =0; i < lines.length; i++)
{
output.println(num+"\t"+array[i]);
}
}
}