Android Open Source - TinyVoxel Data Input Stream






From Project

Back to project page TinyVoxel.

License

The source code is released under:

GNU General Public License

If you think the Android project TinyVoxel listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.// w w  w .jav a 2 s .c  om
 */

package com.toet.TinyVoxel.Importer;

/**
 *
 * @author Kajos
 */
/*
 * Copyright 2010 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import java.io.*;


public class DataInputStream extends InputStream implements DataInput {

  private final InputStream is;

  public DataInputStream(final InputStream is) {
    this.is = is;
  }

  @Override
  public int read () throws IOException {
    return is.read();
  }

  public boolean readBoolean () throws IOException {
    return readByte() != 0;
  }

  public byte readByte () throws IOException {
    int i = read();
    if (i == -1) {
      throw new EOFException();
    }
    return (byte)i;
  }

  public char readChar () throws IOException {
    int a = is.read();
    int b = readUnsignedByte();
    return (char)((a << 8) | b);
  }

  public double readDouble () throws IOException {
    return Double.longBitsToDouble(readLong());
  }

  public void readFully (byte[] b) throws IOException {
    readFully(b, 0, b.length);
  }

  public void readFully (byte[] b, int off, int len) throws IOException {
    while (len > 0) {
      int count = is.read(b, off, len);
      if (count <= 0) {
        throw new EOFException();
      }
      off += count;
      len -= count;
    }
  }

  public int readInt () throws IOException {
    int a = is.read();
    int b = is.read();
    int c = is.read();
    int d = readUnsignedByte();
    return (a << 24) | (b << 16) | (c << 8) | d;
  }

  public String readLine () throws IOException {
            String string = "";
            int ch;
            
            loop:
            while(true) {
                switch(ch = read()) {
                    case -1:
                    case '\n':
                    case '\r':
                        break loop;
                }
                string += (char)ch;
            }
            return string;
  }

  public long readLong () throws IOException {
    long a = readInt();
    long b = readInt() & 0x0ffffffff;
    return (a << 32) | b;
  }

  public short readShort () throws IOException {
    int a = is.read();
    int b = readUnsignedByte();
    return (short)((a << 8) | b);
  }

  public String readUTF () throws IOException {
    int bytes = readUnsignedShort();
    StringBuilder sb = new StringBuilder();

    while (bytes > 0) {
      bytes -= readUtfChar(sb);
    }

    return sb.toString();
  }

  private int readUtfChar (StringBuilder sb) throws IOException {
    int a = readUnsignedByte();
    if ((a & 0x80) == 0) {
      sb.append((char)a);
      return 1;
    }
    if ((a & 0xe0) == 0xc0) {
      int b = readUnsignedByte();
      sb.append((char)(((a & 0x1F) << 6) | (b & 0x3F)));
      return 2;
    }
    if ((a & 0xf0) == 0xe0) {
      int b = readUnsignedByte();
      int c = readUnsignedByte();
      sb.append((char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F)));
      return 3;
    }
    throw new UTFDataFormatException();
  }

  public int readUnsignedByte () throws IOException {
    int i = read();
    if (i == -1) {
      throw new EOFException();
    }
    return i;
  }

  public int readUnsignedShort () throws IOException {
    int a = is.read();
    int b = readUnsignedByte();
    return ((a << 8) | b);
  }

  public int skipBytes (int n) throws IOException {
    // note: This is actually a valid implementation of this method, rendering it quite useless...
    return 0;
  }

  @Override
  public int available () {
    return 0;
  }
  
  @Override
  public void close () throws IOException {
    is.close();
  }

    @Override
    public float readFloat() throws IOException {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}




Java Source Code List

com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration.java
com.badlogic.gdx.backends.gwt.GwtApplication.java
com.badlogic.gdx.backends.gwt.GwtGL20.java
com.badlogic.gdx.backends.gwt.GwtInput.java
com.badlogic.gdx.backends.gwt.GwtNet.java
com.badlogic.gdx.graphics.Pixmap.java
com.toet.TinyVoxel.Config.java
com.toet.TinyVoxel.Game.java
com.toet.TinyVoxel.IOSConfig.java
com.toet.TinyVoxel.IOSLauncher.java
com.toet.TinyVoxel.OuyaController.java
com.toet.TinyVoxel.Time.java
com.toet.TinyVoxel.Character.Character.java
com.toet.TinyVoxel.Debug.LogHandler.java
com.toet.TinyVoxel.GameControllers.CharacterController.java
com.toet.TinyVoxel.GameControllers.CustomTouchPad.java
com.toet.TinyVoxel.GameControllers.KeyBoardController.java
com.toet.TinyVoxel.GameControllers.TouchPadController.java
com.toet.TinyVoxel.Importer.BinvoxImporter.java
com.toet.TinyVoxel.Importer.DataInputStream.java
com.toet.TinyVoxel.Importer.MeshImporter.java
com.toet.TinyVoxel.Renderer.BlockBuilder.java
com.toet.TinyVoxel.Renderer.Floor.java
com.toet.TinyVoxel.Renderer.Manager.java
com.toet.TinyVoxel.Renderer.Bundles.ArrayBundle.java
com.toet.TinyVoxel.Renderer.Bundles.Bundle.java
com.toet.TinyVoxel.Renderer.Bundles.GridBundle.java
com.toet.TinyVoxel.Renderer.Bundles.GridInterface.java
com.toet.TinyVoxel.Renderer.Bundles.Grid.java
com.toet.TinyVoxel.Renderer.Bundles.GroundBundle.java
com.toet.TinyVoxel.Renderer.Bundles.SingleBundle.java
com.toet.TinyVoxel.Renderer.Bundles.TinyGrid.java
com.toet.TinyVoxel.Renderer.Tools.BrushUtils.java
com.toet.TinyVoxel.Renderer.Tools.GridUtils.java
com.toet.TinyVoxel.Renderer.Wrapped.WrappedBoolean.java
com.toet.TinyVoxel.Renderer.Wrapped.WrappedInteger.java
com.toet.TinyVoxel.Screens.GUI.java
com.toet.TinyVoxel.Screens.Menu.java
com.toet.TinyVoxel.Shaders.ShaderManager.java
com.toet.TinyVoxel.Shadow.ShadowManager.java
com.toet.TinyVoxel.Util.Box.java
com.toet.TinyVoxel.Util.FullscreenQuad.java
com.toet.TinyVoxel.Util.JobManager.java
com.toet.TinyVoxel.Util.NonBackedTexture.java
com.toet.TinyVoxel.Util.Position.java
com.toet.TinyVoxel.Util.RLEInputStream.java
com.toet.TinyVoxel.Util.RLEOutputStream.java
com.toet.TinyVoxel.Util.SimpleMath.java
com.toet.TinyVoxel.Util.StreamUtil.java
com.toet.TinyVoxel.android.AndroidConfig.java
com.toet.TinyVoxel.android.AndroidConfig.java
com.toet.TinyVoxel.android.AndroidLauncher.java
com.toet.TinyVoxel.android.AndroidLauncher.java
com.toet.TinyVoxel.client.GwtConfig.java
com.toet.TinyVoxel.client.HtmlLauncher.java
com.toet.TinyVoxel.desktop.DesktopConfig.java
com.toet.TinyVoxel.desktop.DesktopLauncher.java