edu.iris.dmc.seed.io.Buffer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-4-seed Show documentation
Show all versions of java-4-seed Show documentation
Java API to work with seismic dataless seed
The newest version!
package edu.iris.dmc.seed.io;
import java.util.Arrays;
import edu.iris.dmc.io.SeedFormatter;
import edu.iris.dmc.seed.SeedException;
public class Buffer {
private byte[] bytes;
private int offset;
private int sequence;
private char type;
public Buffer(int size) {
bytes = new byte[size];
}
public void add(byte[] buffer) throws SeedException {
for (int i = 0; i < buffer.length; i++) {
if (offset == 0 || offset >= this.bytes.length) {
flush();
this.sequence++;
byte[] s = (SeedFormatter.format(this.sequence, 6) + "" + type + '*').getBytes();
System.arraycopy(s, 0, this.bytes, offset, s.length);
Arrays.copyOfRange(this.bytes, 0, s.length);
offset = s.length;
}
bytes[offset++] = buffer[i];
}
}
public void flush() {
this.bytes = new byte[this.bytes.length];
offset = 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy