Separating into Tech and SysDev

This commit is contained in:
2022-05-07 23:24:08 +02:00
parent ae93dfdacb
commit e49df859aa
88 changed files with 0 additions and 0 deletions

View 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>

View 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>

File diff suppressed because it is too large Load Diff

View File

@@ -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) + " ");
}
}