
write a java program to calculate the time taken to read a given number of files. file names should be given at command line.

Hello Friend,
Try the following code:
import java.io.*;
import java.util.*;
class TimeTakenToReadFiles
{
public static void main(String[] args){
Calendar calendar = new GregorianCalendar();
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
Scanner input=new Scanner(System.in);
System.out.println("Enter File names: ");
String f[]=new String[2];
for(int i=0;i<f.length;i++){
f[i]=input.next();
}
for (int i = 0; i < f.length; i++) {
File file = new File(f[i]);
try {
BufferedReader freader = new BufferedReader(new FileReader(file));
String s;
while ((s = freader.readLine()) != null) {
System.out.println(s);
}
}
catch(Exception e){}
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.