Moved some files and fixed some performance issues
This commit is contained in:
parent
bd7f3542f8
commit
bd58efdd37
6 changed files with 38 additions and 114 deletions
|
|
@ -4,7 +4,9 @@
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="libs/mysql-connector-java-5.0.7-bin.jar"/>
|
<classpathentry kind="lib" path="libs/mysql-connector-java-5.0.7-bin.jar"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||||
<classpathentry kind="lib" path="libs/dom4j-1.6.1.jar"/>
|
<classpathentry kind="lib" path="libs/dom4j-1.6.1.jar" sourcepath="C:/Users/Ziver/Documents/Programmering/Java/libs/dom4j-1.6.1/src"/>
|
||||||
<classpathentry kind="lib" path="libs/wsdl4j-1.6.2.jar"/>
|
<classpathentry kind="lib" path="libs/wsdl4j-1.6.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="libs/javassist.jar" sourcepath="C:/Users/Ziver/Documents/Programmering/Java/libs/javassist-3.12.GA"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
||||||
BIN
libs/javassist.jar
Normal file
BIN
libs/javassist.jar
Normal file
Binary file not shown.
|
|
@ -7,7 +7,7 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
|
||||||
import zutil.struct.DynamicByteArrayStream;
|
import zutil.io.DynamicByteArrayStream;
|
||||||
|
|
||||||
public class Converter {
|
public class Converter {
|
||||||
private Converter(){}
|
private Converter(){}
|
||||||
|
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
package zutil.io;
|
|
||||||
|
|
||||||
import java.io.FilterInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
public class BoundryBufferedInputStream extends FilterInputStream{
|
|
||||||
|
|
||||||
protected BoundryBufferedInputStream(InputStream in) {
|
|
||||||
super(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int read() throws IOException {
|
|
||||||
return in.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int read(byte b[], int off, int len) throws IOException {
|
|
||||||
return in.read(b, off, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long skip(long n) throws IOException {
|
|
||||||
return in.skip(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an estimate of the number of bytes that can be read (or
|
|
||||||
* skipped over) from this input stream without blocking by the next
|
|
||||||
* caller of a method for this input stream. The next caller might be
|
|
||||||
* the same thread or another thread. A single read or skip of this
|
|
||||||
* many bytes will not block, but may read or skip fewer bytes.
|
|
||||||
* <p>
|
|
||||||
* This method returns the result of {@link #in in}.available().
|
|
||||||
*
|
|
||||||
* @return an estimate of the number of bytes that can be read (or skipped
|
|
||||||
* over) from this input stream without blocking.
|
|
||||||
* @exception IOException if an I/O error occurs.
|
|
||||||
*/
|
|
||||||
public int available() throws IOException {
|
|
||||||
return in.available();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks the current position in this input stream. A subsequent
|
|
||||||
* call to the <code>reset</code> method repositions this stream at
|
|
||||||
* the last marked position so that subsequent reads re-read the same bytes.
|
|
||||||
* <p>
|
|
||||||
* The <code>readlimit</code> argument tells this input stream to
|
|
||||||
* allow that many bytes to be read before the mark position gets
|
|
||||||
* invalidated.
|
|
||||||
* <p>
|
|
||||||
* This method simply performs <code>in.mark(readlimit)</code>.
|
|
||||||
*
|
|
||||||
* @param readlimit the maximum limit of bytes that can be read before
|
|
||||||
* the mark position becomes invalid.
|
|
||||||
* @see java.io.FilterInputStream#in
|
|
||||||
* @see java.io.FilterInputStream#reset()
|
|
||||||
*/
|
|
||||||
public synchronized void mark(int readlimit) {
|
|
||||||
in.mark(readlimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Repositions this stream to the position at the time the
|
|
||||||
* <code>mark</code> method was last called on this input stream.
|
|
||||||
* <p>
|
|
||||||
* This method
|
|
||||||
* simply performs <code>in.reset()</code>.
|
|
||||||
* <p>
|
|
||||||
* Stream marks are intended to be used in
|
|
||||||
* situations where you need to read ahead a little to see what's in
|
|
||||||
* the stream. Often this is most easily done by invoking some
|
|
||||||
* general parser. If the stream is of the type handled by the
|
|
||||||
* parse, it just chugs along happily. If the stream is not of
|
|
||||||
* that type, the parser should toss an exception when it fails.
|
|
||||||
* If this happens within readlimit bytes, it allows the outer
|
|
||||||
* code to reset the stream and try another parser.
|
|
||||||
*
|
|
||||||
* @exception IOException if the stream has not been marked or if the
|
|
||||||
* mark has been invalidated.
|
|
||||||
* @see java.io.FilterInputStream#in
|
|
||||||
* @see java.io.FilterInputStream#mark(int)
|
|
||||||
*/
|
|
||||||
public synchronized void reset() throws IOException {
|
|
||||||
in.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -12,8 +12,8 @@ import java.io.RandomAccessFile;
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*/
|
*/
|
||||||
public class BufferedRandomAccessFile extends RandomAccessFile{
|
public class BufferedRandomAccessFile extends RandomAccessFile{
|
||||||
// The size of the buffer
|
// The size of the buffer in Byte
|
||||||
private int BUF_SIZE = 256;
|
private int BUF_SIZE = 64*1024;
|
||||||
|
|
||||||
// The Buffer
|
// The Buffer
|
||||||
byte buffer[];
|
byte buffer[];
|
||||||
|
|
@ -73,22 +73,6 @@ public class BufferedRandomAccessFile extends RandomAccessFile{
|
||||||
buffer = new byte[BUF_SIZE];
|
buffer = new byte[BUF_SIZE];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the next byte in the buffer
|
|
||||||
*/
|
|
||||||
public final int read() throws IOException{
|
|
||||||
if(buf_pos >= buf_end) {
|
|
||||||
if(fillBuffer() < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(buf_end == 0) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
buf_pos++;
|
|
||||||
return buffer[buf_pos-1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads in data from the file to the buffer
|
* Reads in data from the file to the buffer
|
||||||
*
|
*
|
||||||
|
|
@ -116,6 +100,22 @@ public class BufferedRandomAccessFile extends RandomAccessFile{
|
||||||
file_pos = super.getFilePointer();
|
file_pos = super.getFilePointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the next byte in the buffer
|
||||||
|
*/
|
||||||
|
public final int read() throws IOException{
|
||||||
|
if(buf_pos >= buf_end) {
|
||||||
|
if(fillBuffer() < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(buf_end == 0) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
buf_pos++;
|
||||||
|
return buffer[buf_pos-1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the given array with data from the buffer
|
* Fills the given array with data from the buffer
|
||||||
*
|
*
|
||||||
|
|
@ -135,13 +135,26 @@ public class BufferedRandomAccessFile extends RandomAccessFile{
|
||||||
* @return the amount of bytes read or -1 if eof
|
* @return the amount of bytes read or -1 if eof
|
||||||
*/
|
*/
|
||||||
public int read(byte b[], int off, int len) throws IOException {
|
public int read(byte b[], int off, int len) throws IOException {
|
||||||
|
if(buf_pos >= buf_end) {
|
||||||
|
if(fillBuffer() < 0)
|
||||||
|
return -1; // EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy from buffer
|
||||||
int leftover = buf_end - buf_pos;
|
int leftover = buf_end - buf_pos;
|
||||||
if(len <= leftover) {
|
if(len <= leftover) {
|
||||||
System.arraycopy(buffer, buf_pos, b, off, len);
|
System.arraycopy(buffer, buf_pos, b, off, len);
|
||||||
buf_pos += len;
|
buf_pos += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < len; i++) {
|
|
||||||
|
System.arraycopy(buffer, buf_pos, b, off, leftover);
|
||||||
|
int n = super.read(b, off+leftover, len-leftover );
|
||||||
|
fillBuffer();
|
||||||
|
if( n >= 0 )
|
||||||
|
return leftover + n;
|
||||||
|
return leftover;
|
||||||
|
/*for(int i = 0; i < len; i++) {
|
||||||
int c = this.read();
|
int c = this.read();
|
||||||
if(c != -1)
|
if(c != -1)
|
||||||
b[off+i] = (byte)c;
|
b[off+i] = (byte)c;
|
||||||
|
|
@ -149,7 +162,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return len;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package zutil.struct;
|
package zutil.io;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue