Make writePrimitive*() and readPrimitive*() methods public.

These utility methods are useful for client code to read/write arrays of
primitive types.
This commit is contained in:
Andrew Selden 2014-04-07 10:38:57 -07:00
parent f283a9f3a5
commit fb338ef753
2 changed files with 8 additions and 8 deletions

View File

@ -446,7 +446,7 @@ public abstract class StreamInput extends InputStream {
} }
} }
private Object readPrimitiveIntArray() throws IOException { public int[] readPrimitiveIntArray() throws IOException {
int length = readVInt(); int length = readVInt();
int[] values = new int[length]; int[] values = new int[length];
for(int i=0; i<length; i++) { for(int i=0; i<length; i++) {
@ -455,7 +455,7 @@ public abstract class StreamInput extends InputStream {
return values; return values;
} }
private Object readPrimitiveLongArray() throws IOException { public long[] readPrimitiveLongArray() throws IOException {
int length = readVInt(); int length = readVInt();
long[] values = new long[length]; long[] values = new long[length];
for(int i=0; i<length; i++) { for(int i=0; i<length; i++) {
@ -464,7 +464,7 @@ public abstract class StreamInput extends InputStream {
return values; return values;
} }
private Object readPrimitiveFloatArray() throws IOException { public float[] readPrimitiveFloatArray() throws IOException {
int length = readVInt(); int length = readVInt();
float[] values = new float[length]; float[] values = new float[length];
for(int i=0; i<length; i++) { for(int i=0; i<length; i++) {
@ -473,7 +473,7 @@ public abstract class StreamInput extends InputStream {
return values; return values;
} }
private Object readPrimitiveDoubleArray() throws IOException { public double[] readPrimitiveDoubleArray() throws IOException {
int length = readVInt(); int length = readVInt();
double[] values = new double[length]; double[] values = new double[length];
for(int i=0; i<length; i++) { for(int i=0; i<length; i++) {

View File

@ -425,28 +425,28 @@ public abstract class StreamOutput extends OutputStream {
} }
} }
private void writePrimitiveIntArray(int[] value) throws IOException { public void writePrimitiveIntArray(int[] value) throws IOException {
writeVInt(value.length); writeVInt(value.length);
for (int i=0; i<value.length; i++) { for (int i=0; i<value.length; i++) {
writeInt(value[i]); writeInt(value[i]);
} }
} }
private void writePrimitiveLongArray(long[] value) throws IOException { public void writePrimitiveLongArray(long[] value) throws IOException {
writeVInt(value.length); writeVInt(value.length);
for (int i=0; i<value.length; i++) { for (int i=0; i<value.length; i++) {
writeLong(value[i]); writeLong(value[i]);
} }
} }
private void writePrimitiveFloatArray(float[] value) throws IOException { public void writePrimitiveFloatArray(float[] value) throws IOException {
writeVInt(value.length); writeVInt(value.length);
for (int i=0; i<value.length; i++) { for (int i=0; i<value.length; i++) {
writeFloat(value[i]); writeFloat(value[i]);
} }
} }
private void writePrimitiveDoubleArray(double[] value) throws IOException { public void writePrimitiveDoubleArray(double[] value) throws IOException {
writeVInt(value.length); writeVInt(value.length);
for (int i=0; i<value.length; i++) { for (int i=0; i<value.length; i++) {
writeDouble(value[i]); writeDouble(value[i]);