LittleEndianDataInputStream.java 3 KB
package com.google.common.io;

import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

@Beta
public final class LittleEndianDataInputStream
  extends FilterInputStream
  implements DataInput
{
  public LittleEndianDataInputStream(InputStream paramInputStream)
  {
    super((InputStream)Preconditions.checkNotNull(paramInputStream));
  }
  
  private byte a()
    throws IOException, EOFException
  {
    int i = this.in.read();
    if (-1 == i) {
      throw new EOFException();
    }
    return (byte)i;
  }
  
  public final boolean readBoolean()
    throws IOException
  {
    return readUnsignedByte() != 0;
  }
  
  public final byte readByte()
    throws IOException
  {
    return (byte)readUnsignedByte();
  }
  
  public final char readChar()
    throws IOException
  {
    return (char)readUnsignedShort();
  }
  
  public final double readDouble()
    throws IOException
  {
    return Double.longBitsToDouble(readLong());
  }
  
  public final float readFloat()
    throws IOException
  {
    return Float.intBitsToFloat(readInt());
  }
  
  public final void readFully(byte[] paramArrayOfByte)
    throws IOException
  {
    ByteStreams.readFully(this, paramArrayOfByte);
  }
  
  public final void readFully(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    ByteStreams.readFully(this, paramArrayOfByte, paramInt1, paramInt2);
  }
  
  public final int readInt()
    throws IOException
  {
    byte b1 = a();
    byte b2 = a();
    byte b3 = a();
    return Ints.fromBytes(a(), b3, b2, b1);
  }
  
  public final String readLine()
  {
    throw new UnsupportedOperationException("readLine is not supported");
  }
  
  public final long readLong()
    throws IOException
  {
    byte b1 = a();
    byte b2 = a();
    byte b3 = a();
    byte b4 = a();
    byte b5 = a();
    byte b6 = a();
    byte b7 = a();
    return Longs.fromBytes(a(), b7, b6, b5, b4, b3, b2, b1);
  }
  
  public final short readShort()
    throws IOException
  {
    return (short)readUnsignedShort();
  }
  
  public final String readUTF()
    throws IOException
  {
    return new DataInputStream(this.in).readUTF();
  }
  
  public final int readUnsignedByte()
    throws IOException
  {
    int i = this.in.read();
    if (i < 0) {
      throw new EOFException();
    }
    return i;
  }
  
  public final int readUnsignedShort()
    throws IOException
  {
    byte b = a();
    return Ints.fromBytes((byte)0, (byte)0, a(), b);
  }
  
  public final int skipBytes(int paramInt)
    throws IOException
  {
    return (int)this.in.skip(paramInt);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/io/LittleEndianDataInputStream.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */