Methods Summary |
---|
public int | available()Gets the number of bytes remaining to be read.
if (fileDecoder == null) {
throw new IOException();
}
return bytesRemain(fileDecoder);
|
private static native int | bytesRemain(java.lang.Object fileDecoder)
|
private static native java.lang.Object | clone(java.lang.Object source)
|
public void | close()
fileDecoder = null;
|
private static java.lang.String | fixResourceName(java.lang.String name)Fixes the resource name to be conformant with the CLDC 1.0
specification. We are not allowed to use "../" to get outside
of the .jar file.
Vector dirVector = new Vector();
int startIdx = 0;
int endIdx = 0;
String curDir;
while ((endIdx = name.indexOf('/", startIdx)) != -1) {
if (endIdx == startIdx) {
// We have a leading '/' or two consecutive '/'s
startIdx++;
continue;
}
curDir = name.substring(startIdx, endIdx);
startIdx = endIdx + 1;
if (curDir.equals(".")) {
// Ignore a single '.' directory
continue;
}
if (curDir.equals("..")) {
// Go up a level
try {
dirVector.removeElementAt(dirVector.size()-1);
} catch (ArrayIndexOutOfBoundsException aioobe) {
// "/../resource" Not allowed!
throw new IOException();
}
continue;
}
dirVector.addElement(curDir);
}
// save directory structure
StringBuffer dirName = new StringBuffer();
int nelements = dirVector.size();
for (int i = 0; i < nelements; ++i) {
dirName.append((String)dirVector.elementAt(i));
dirName.append("/");
}
// save filename
if (startIdx < name.length()) {
String filename = name.substring(startIdx);
// Throw IOE if the resource ends with ".class", but, not
// if the entire name is ".class"
if ((filename.endsWith(".class")) &&
(! ".class".equals(filename))) {
throw new IOException();
}
dirName.append(name.substring(startIdx));
}
return dirName.toString();
|
public void | mark(int readlimit)Remembers current position in ResourceInputStream so that
subsequent call to reset will rewind the stream
to the saved position.
if (fileDecoder != null) {
savedDecoder = clone(fileDecoder);
}
|
public boolean | markSupported()Indicates that this ResourceInputStream supports mark/reset
functionality
return true;
|
private static native java.lang.Object | open(java.lang.String name)
|
public int | read()Reads the next byte of data from the input stream.
// Fix for CR 6303054
if (fileDecoder == null) {
throw new IOException();
}
return readByte(fileDecoder);
|
public int | read(byte[] b, int off, int len)Reads bytes into a byte array.
// Fix for CR 6303054
if (fileDecoder == null) {
throw new IOException();
}
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
}
return readBytes(fileDecoder, b, off, len);
|
private static native int | readByte(java.lang.Object fileDecoder)
|
private static native int | readBytes(java.lang.Object fileDecoder, byte[] b, int off, int len)
|
public void | reset()Repositions this stream to the position at the time the
mark method was last called on this input stream.
if (fileDecoder == null || savedDecoder == null) {
throw new IOException();
}
fileDecoder = clone(savedDecoder);
|