
org.monte.media.io.AppendableByteArrayInputStream Maven / Gradle / Ivy
/*
* @(#)AppendableByteArrayInputStream.java 1.0 2011-08-28
*
* Copyright (c) 2011 Werner Randelshofer, Goldau, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package org.monte.media.io;
import java.io.ByteArrayInputStream;
import java.util.zip.Adler32;
/**
* A {@code ByteArrayInputStream} which allows to replace the byte buffer underneath.
*
* @author Werner Randelshofer
* @version 1.0 2011-08-28 Created.
*/
public class AppendableByteArrayInputStream extends ByteArrayInputStream {
public AppendableByteArrayInputStream(byte[] buf, int offset, int length) {
super(buf, offset, length);
// System.out.println("AppendableByteArrayInputStream pos="+pos+" count="+count);
}
public AppendableByteArrayInputStream(byte[] buf) {
super(buf);
// System.out.println("AppendableByteArrayInputStream pos="+pos+" count="+count);
}
@Override
public synchronized int read() {
int b = super.read();
/*
if (b!=-1) {
String hex="0"+Integer.toHexString(b);
System.out.println(hex.substring(hex.length()-2));
}*/
return b;
}
@Override
public synchronized int read(byte[] b, int off, int len) {
// System.out.println("AppendableByteArrayInputStream.read... pos="+pos+" count="+count);
int count = super.read(b, off, len);
/*
if (count>0) {
for (int i=0;i© 2015 - 2025 Weber Informatics LLC | Privacy Policy