Separating into Tech and SysDev
This commit is contained in:
6
Technology/ClassicIoManBuffered/.classpath
Normal file
6
Technology/ClassicIoManBuffered/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
Technology/ClassicIoManBuffered/.project
Normal file
17
Technology/ClassicIoManBuffered/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ClassicIoManBuffered</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11776
Technology/ClassicIoManBuffered/input.txt
Normal file
11776
Technology/ClassicIoManBuffered/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author KAJE
|
||||
*
|
||||
*/
|
||||
|
||||
public class ClassicIoManBuffered {
|
||||
|
||||
private static int lineCount(String path, boolean doDance){
|
||||
if ( ! doDance ) return -1;
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream( path );
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte buf[] = new byte[2048];
|
||||
int cnt = 0;
|
||||
int n;
|
||||
try {
|
||||
while ((n = fis.read(buf)) != -1) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (buf[i] == '\n') cnt++;
|
||||
}
|
||||
}
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
long startTime = System.nanoTime();
|
||||
lineCount("", false);
|
||||
long dryRun = System.nanoTime() - startTime;
|
||||
startTime = System.nanoTime();
|
||||
int lines = lineCount("input.txt", true);
|
||||
long stopTime = System.nanoTime();
|
||||
System.out.println("Lines: " + String.valueOf(lines));
|
||||
System.out.println("Time it took: " + (stopTime - startTime - dryRun) + " ");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user