Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,25 @@
/**
* Created by sherxon on 4/23/17. https://github.com/sherxon/AlgoDS/tree/master/src/oi
*/
public class UsingBufferedStreams {
public class UsingBufferedReader {
public static void main(String[] args) throws IOException {

//-------------- Test reading 1 MB file. --------------------
StopWatch.start();

BufferedInputStream inputStream= new BufferedInputStream(new FileInputStream(new File(DumpDataWriter.input1MB)));
while (inputStream.read()!=-1){}

long duration = StopWatch.stop();
System.out.println(duration + " milsec");

inputStream.close();

//-------------- Test reading 10 MB file. --------------------
StopWatch.start();

BufferedInputStream inputStream2= new BufferedInputStream(new FileInputStream(new File(DumpDataWriter.input10MB)));
while (inputStream2.read()!=-1){}
if (args.length < 1) {
System.out.println("Please provide a file name as a command line argument.");
return;
}

long duration2 = StopWatch.stop();
System.out.println(duration2 + " milsec");

inputStream2.close();
String filename = args[0];

/*
//-------------- Test reading 100 MB file. --------------------
StopWatch.start();

BufferedInputStream inputStream3= new BufferedInputStream(new FileInputStream(new File(DumpDataWriter.input100MB)));
while (inputStream3.read()!=-1){}
BufferedReader inputStream = new BufferedReader(new FileReader(filename));
while (inputStream.read() != -1) {}

long duration3 = StopWatch.stop();
System.out.println(duration3 + " milsec");

inputStream3.close();

//-------------- Test reading 1000 MB file. --------------------
StopWatch.start();
long duration = StopWatch.stop();
System.out.println("Reading file: " + filename);
System.out.println(duration + " milsec");

BufferedInputStream inputStream4= new BufferedInputStream(new FileInputStream(new File(DumpDataWriter.input1000MB)));
while (inputStream4.read()!=-1){}
long duration4 = StopWatch.stop();
System.out.println(duration4 + " milsec");

inputStream4.close();
*/
inputStream.close();
}
}