( Last Modified: 2008 October 20th 02:34 PM )
The Java Library
Create an uncompressed jar file with the java.util.jar library
Here is how to create an uncompressed jar using the java.util.jar api. I found it very diffucult to find any documentation or help with this.
JarOutputStream jar = new JarOutputStream(new FileOutputStream(fJarPath));
...
private static void addFile( JarOutputStream jar, String fileName, File source)
throws IOException {
JarEntry newEntry = new JarEntry(fileName);
byte[] readBuffer = new byte[4096];
// No Compression
newEntry.setMethod(ZipEntry.STORED);
// Need to do this step when compression is off
InputStream contentStream = new FileInputStream( source );
JarPackagerUtil.calculateCrcAndSize(newEntry, contentStream, readBuffer);
// Set modification time
long lastModified = System.currentTimeMillis();
newEntry.setTime(lastModified);
// Read the file and write it to the Jar
try {
jar.putNextEntry(newEntry);
contentStream = new FileInputStream( source );
int count;
while ((count = contentStream.read(readBuffer, 0, readBuffer.length)) != -1)
jar.write(readBuffer, 0, count);
} finally {
if (contentStream != null)
contentStream.close();
}
...
jar.close();
Measuring Sub Millisecond Time
System.nanoTime() in Java 5
"The specification of nanoTime is very clear that it does not bear any relation to absolute time:"
"This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary time (perhaps in the future, so values may be negative)."
long time = 0;
long newTime;
long smaller = 9999999999999L;
for (int i = 0; i < 100000; i++) {
time = System.nanoTime();
newTime = System.nanoTime();
smaller = Math.min(smaller, newTime - time);
}
System.out.println("Smallest nano interval measured: " + smaller);
System.out.println("Current time millis: " + System.currentTimeMillis());
System.out.println("Nano time: " + System.nanoTime());
Windows Clock Interval
windows only has ~10ms interval clock?
Microsoft SQL server:
server makes the OS calls that hook into the system processor cycle count, which (for the sub GHz systems that were current when SQL was designed) ran at a period such that a field giving a value in nanos would would be guarenteed unique for each update and could be used to order events. It's not synchronised to the real time to that accuracy.
the clock interval for most x86 multiprocessors is about 15 milliseconds
ClockRes - tool for measuring clock interval
single processor boards have a clock interval of about 10 milliseconds.
( Page Created: 2008 October 20th 02:34 PM )