Hi guys I have got a file contain large amount of numbers
I have tried to use the following code to read it from the file, but it is super slow anyone can help to reduce the time? Thanks.
following is my code to read it in a very slow way
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
public class FileInput {
public static void main(String[] args) {
Scanner scan1 = new Scanner(System.in);
String filename = scan1.nextLine();
File file = new File(filename);
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while (dis.available() != 0) {
System.out.println(dis.readLine());
}
fis.close();
bis.close();
dis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}