FileInput.java :  » Graphics-3D-2D-OpenGL » leetdev3da » LeetDev » a3d » Android Open Source

Android Open Source » Graphics 3D 2D OpenGL » leetdev3da 
leetdev3da » LeetDev » a3d » FileInput.java
package LeetDev.a3d;

import java.io.DataInputStream;

public class FileInput {
  
  private DataInputStream m_dis = null;

  public FileInput(final String filename) throws Exception
  {
    m_dis=new DataInputStream(getClass().getResourceAsStream(filename));
  }
  
  public void close()
  {
    try
    {
      m_dis.close();
    }
    catch(Exception e)
    {
    }
  }
  
  public int popInt() throws Exception
  {
    return(m_dis.readInt());
  }
  
  public short popShort() throws Exception
  {
    return(m_dis.readShort());
  }
  
  public float popFloat() throws Exception
  {
    return(((float)m_dis.readInt())/65536.0f);
  }
  
  public int popFixed() throws Exception
  {
    return(m_dis.readInt());
  }
  
  public String popString() throws Exception
  {
    StringBuffer b=new StringBuffer();
    while(true)
    {
      byte tmp=m_dis.readByte();
      if(tmp==0) {break;}
      char tc=(char)tmp;
      b.append(tc);
    }
    return(b.toString());
  }

  public byte popByte() throws Exception
  {
    return(m_dis.readByte());
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.