下面列出了怎么用javax.imageio.stream.FileCacheImageOutputStream的API类实例代码及写法,或者点击链接到github查看源代码。
public static void main(String[] args) throws IOException {
OutputStream ostream = new ByteArrayOutputStream();
File f = null;
FileCacheImageOutputStream fcios =
new FileCacheImageOutputStream(ostream, f);
fcios.writeBit(1);
fcios.write(96);
fcios.seek(0);
int r1 = fcios.read();
if (r1 != 128 ) {
throw new RuntimeException("Failed, first byte is " + r1);
}
int r2 = fcios.read();
if (r2 != 96) {
throw new RuntimeException("Failed, second byte is " + r2);
}
}
public static void main(String[] args) throws IOException {
OutputStream ostream = new ByteArrayOutputStream();
File f = null;
FileCacheImageOutputStream fcios =
new FileCacheImageOutputStream(ostream, f);
fcios.writeBit(1);
fcios.write(96);
fcios.seek(0);
int r1 = fcios.read();
if (r1 != 128 ) {
throw new RuntimeException("Failed, first byte is " + r1);
}
int r2 = fcios.read();
if (r2 != 96) {
throw new RuntimeException("Failed, second byte is " + r2);
}
}
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
if (this.cacheDir != null) {
return new FileCacheImageOutputStream(os, this.cacheDir);
}
else {
return new MemoryCacheImageOutputStream(os);
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
if (this.cacheDir != null) {
return new FileCacheImageOutputStream(os, this.cacheDir);
}
else {
return new MemoryCacheImageOutputStream(os);
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
if (this.cacheDir != null) {
return new FileCacheImageOutputStream(os, this.cacheDir);
}
else {
return new MemoryCacheImageOutputStream(os);
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public static void main(String[] args) throws IOException {
OutputStream ostream = new ByteArrayOutputStream();
FileCacheImageOutputStream fcios =
new FileCacheImageOutputStream(ostream, null);
test(fcios);
MemoryCacheImageOutputStream mcios =
new MemoryCacheImageOutputStream(ostream);
test(mcios);
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException {
if (this.cacheDir != null) {
return new FileCacheImageOutputStream(os, this.cacheDir);
}
else {
return new MemoryCacheImageOutputStream(os);
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public static void main(String[] args) throws IOException {
OutputStream ostream = new ByteArrayOutputStream();
FileCacheImageOutputStream fcios =
new FileCacheImageOutputStream(ostream, null);
test(fcios);
MemoryCacheImageOutputStream mcios =
new MemoryCacheImageOutputStream(ostream);
test(mcios);
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}
public ImageOutputStream createOutputStreamInstance(Object output,
boolean useCache,
File cacheDir)
throws IOException {
if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}
}