当前位置: 首页>>代码示例>>Java>>正文


Java LittleEndianDataInputStream.read方法代码示例

本文整理汇总了Java中com.google.common.io.LittleEndianDataInputStream.read方法的典型用法代码示例。如果您正苦于以下问题:Java LittleEndianDataInputStream.read方法的具体用法?Java LittleEndianDataInputStream.read怎么用?Java LittleEndianDataInputStream.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.io.LittleEndianDataInputStream的用法示例。


在下文中一共展示了LittleEndianDataInputStream.read方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readBlocks

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
public void readBlocks(InputStream is, int nBlocks) throws IOException {

        LittleEndianDataInputStream lis = new LittleEndianDataInputStream(is);
        for (int i = 0; i < nBlocks; i++) {

            int compressionMethod = lis.read();
            int contentType = lis.read();
            int contentId = ITF8.readUnsignedITF8(lis);
            int size = ITF8.readUnsignedITF8(lis);
            int rawSize = ITF8.readUnsignedITF8(lis);

            byte[] blockData = new byte[size];
            lis.readFully(blockData);

            blockData = uncompress(blockData, compressionMethod);


            String tmp = new String(blockData);

            if (major >= 3) {
                int checksum = CramInt.int32(lis);
            }
        }
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:25,代码来源:CRAMFile.java

示例2: readTile

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
private Tile readTile(LittleEndianDataInputStream stream, int x, int y) throws IOException {
    Tile tile = new Tile(tiles[x][y]);
    int attributes = stream.read();
    if (attributes==1 || attributes==3) {
        int length = stream.read();
        byte[] textBytes = new byte[length];
        stream.read(textBytes);
        String text = new String(textBytes, "US-ASCII");
        tile.setLabel(new Label(Font.decode("Arial-18"), text, new Color(0, 0, 0)), false);
        stream.skipBytes(3);
    }
    if (attributes==2 || attributes==3) {
        stream.skipBytes(4);
    }
    int terrain = stream.read();
    GroundData ground = WAKData.grounds.get(terrain);
    tile.setGround(ground, RoadDirection.CENTER, false);
    int itemsNumber = stream.readInt();
    
    for (int i=0; i<itemsNumber; i++) {
        readObject(stream, tile);
    }
    
    return tile;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:26,代码来源:Map.java

示例3: readObject

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
private void readObject(LittleEndianDataInputStream stream, Tile tile) throws IOException {
    int pos = stream.read();
    int type = stream.read();
    if (pos==2 || pos==10) {
        WallData wallData = WAKData.walls.get(type);
        if (pos==2) {
            Tile t = getTile(tile, 0, 1);
            if (t!=null) {
                t.setHorizontalWall(wallData, 0, false);
            }
        }
        if (pos==10) {
            tile.setVerticalWall(wallData, 0, false);
        }
        stream.skipBytes(1);
    }
    else {
        ObjectLocation loc = WAKData.locations.get(pos);
        GameObjectData data = WAKData.objects.get(type);
        if (data!=null) {
            tile.setGameObject(data, loc, 0);
        }
        stream.skipBytes(1);
    }
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:26,代码来源:Map.java

示例4: readData

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
public static ComponentData readData(
		LittleEndianDataInputStream dataStream, short fileversion)
		throws IOException {
	ComponentData data = new ComponentData();
	data.lengthOfComponentName = dataStream.readInt();
	data.totalNumberOfComponents = dataStream.readInt();
	data.numberOfOilComponents = dataStream.readInt();
	data.numberOfChemComponents = dataStream.readInt();
	data.numberOfParticleMaterialComponents = dataStream.readInt();
	// gas particles from version 23
	if (fileversion >= GRF.GRFFILEGASVERSION) {
		data.numberOfGasComponents = dataStream.readInt(); // number gas
															// components
	}

	byte[] componentName = new byte[data.lengthOfComponentName];
	for (int i = 0; i < data.totalNumberOfComponents; i++) {
		dataStream.read(componentName);
		data.components.add(new Component(new String(componentName),
				dataStream.readFloat() /* density */, dataStream
						.readFloat() /* background concentration */,
				dataStream.readShort() /* is degradable */
		));
	}
	return data;
}
 
开发者ID:SINTEF-EnvironmentalTechnology,项目名称:GRF2NETCDF,代码行数:27,代码来源:ComponentData.java

示例5: readString

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
protected String readString(LittleEndianDataInputStream s) throws IOException {
	int len = s.readInt();
	byte[] b = new byte[len];
	s.readFully(b);
	String str = new String(b);
	while (len++ % 4 != 0) s.read();
	return str;
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:9,代码来源:IfcGeomServerClient.java

示例6: Map

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
private Map(LittleEndianDataInputStream stream) throws DeedPlannerException, IOException {
    byte[] wakWordBytes = new byte[3];
    stream.read(wakWordBytes);
    String wakWordString = new String(wakWordBytes, "US-ASCII");
    if (!"WMP".equals(wakWordString)) {
        throw new DeedPlannerException("Not a WAK map");
    }
    stream.skipBytes(20);
    width = Math.max(stream.readInt(), 50);
    height = Math.max(stream.readInt(), 50);
    tiles = new Tile[width+1][height+1];
    for (int i=0; i<=width; i++) {
        for (int i2=0; i2<=height; i2++) {
            tiles[i][i2] = new Tile(this, i, i2);
        }
    }
    
    boolean bigMap = width > 255 || height> 255;
    stream.skipBytes(34);
    int tileCount = stream.readInt();
    
    for (int i=0; i<tileCount; i++) {
        final int x = readCoordinate(stream, bigMap);
        final int y = height - readCoordinate(stream, bigMap) - 1;
        final int layers = stream.read();
        if (layers==1 || layers==3) {
            tiles[x][y] = readTile(stream, x, y);
        }
        if (layers==2 || layers==3) {
            readTile(stream, x, y);
        }
    }
    
    createHeightData();
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:36,代码来源:Map.java

示例7: readCoordinate

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
private int readCoordinate(LittleEndianDataInputStream stream, boolean bigMap) throws IOException {
    if (bigMap) {
        return stream.readInt();
    }
    else {
        return stream.read();
    }
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:9,代码来源:Map.java

示例8: getString

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
/**
 * @param myStream
 * @param length
 * @return String with length length read from myStream
 * @throws IOException 
 */
public static String getString(LittleEndianDataInputStream myStream, int length) throws IOException {
	byte[] b = new byte[length];
	myStream.read(b);

	return new String(b);

}
 
开发者ID:SINTEF-EnvironmentalTechnology,项目名称:GRF2NETCDF,代码行数:14,代码来源:BinaryDataDAO.java

示例9: readData

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
/**
 * 
 * @param dataStream
 * @return
 * @throws IOException
 */
public static BinaryHeader readData(
		LittleEndianDataInputStream dataStream) throws IOException {
	byte[] header = new byte[BinaryHeader.size];
	dataStream.read(header);
	return new BinaryHeader(header);
}
 
开发者ID:SINTEF-EnvironmentalTechnology,项目名称:GRF2NETCDF,代码行数:13,代码来源:BinaryHeader.java

示例10: readCompiledFile

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
/**
 * Reads compiled resource data files and adds them to consumers
 *
 * @param compiledFileStream First byte is number of compiled files represented in this file. Next
 *     8 bytes is a long indicating the length of the metadata describing the compiled file. Next
 *     N bytes is the metadata describing the compiled file. The remaining bytes are the actual
 *     original file.
 * @param consumers
 * @param fqnFactory
 * @throws IOException
 */
private void readCompiledFile(
    LittleEndianDataInputStream compiledFileStream,
    KeyValueConsumers consumers,
    Factory fqnFactory) throws IOException {
  //Skip aligned size. We don't need it here.
  Preconditions.checkArgument(compiledFileStream.skipBytes(8) == 8);

  int resFileHeaderSize = compiledFileStream.readInt();

  //Skip data payload size. We don't need it here.
  Preconditions.checkArgument(compiledFileStream.skipBytes(8) == 8);

  byte[] file = new byte[resFileHeaderSize];
  compiledFileStream.read(file, 0, resFileHeaderSize);
  CompiledFile compiledFile = CompiledFile.parseFrom(file);

  Path sourcePath = Paths.get(compiledFile.getSourcePath());
  FullyQualifiedName fqn = fqnFactory.parse(sourcePath);
  DataSource dataSource = DataSource.of(sourcePath);

  if (consumers != null) {
    consumers.overwritingConsumer.accept(fqn, DataValueFile.of(dataSource));
  }

  for (CompiledFile.Symbol exportedSymbol : compiledFile.getExportedSymbolList()) {
    if (!exportedSymbol.getResourceName().startsWith("android:")) {
      // Skip writing resource xml's for resources in the sdk
      FullyQualifiedName symbolFqn =
          fqnFactory.create(
              ResourceType.ID, exportedSymbol.getResourceName().replaceFirst("id/", ""));

      DataResourceXml dataResourceXml =
          DataResourceXml.from(null, dataSource, ResourceType.ID, null);
      consumers.combiningConsumer.accept(symbolFqn, dataResourceXml);
    }
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:49,代码来源:AndroidCompiledDataDeserializer.java

示例11: updateFromADFile

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
public void updateFromADFile(int attempt) {
    error = false;
    if (attempt > 2) {
        failCheckCount++;
        if (failCheckCount > 5) {

            KRFAM.log(codeName + " > Failed to read A.D > Abort");
            KRFAM.Toast("Failed to access '" + codeName + "' A.D.\nDid you allow KRFAM root access?");
            return;
        }
        KRFAM.delayAction(new Runnable() {
            @Override
            public void run() {
                updateFromADFile();
            }
        }, 200*failCheckCount);
        error = true;
        return;
    }
    if (installed == true) {
        if (adFile.exists()) {
            try {
                boolean flag1 = false;

                InputStream is = new FileInputStream(SaveFile);
                LittleEndianDataInputStream binaryReader = new LittleEndianDataInputStream(is);

                int num1 = binaryReader.readInt();
                int num2 = num1 & 0x7F;
                KRFAM.log("Save data Version: " + ((num1 & 65280) >> 8));
                int b = (binaryReader.readByte() & 0xff);
                int count1 = b - num2;

                byte[] iv = new byte[count1];
                KRFAM.log("IV Length: " + count1);
                binaryReader.read(iv, 0, count1);
                for (int index = 0; index < iv.length; ++index) iv[index] -= (byte) (96 + (int) (byte) index);
                String _iv = new String(iv);
                KRFAM.log("IV: " + _iv);
                int count2 = binaryReader.readInt();
                byte[] numArray = new byte[count2];
                binaryReader.read(numArray, 0, count2);

                if (!flag1)
                {
                    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
                    SecretKeySpec skeySpec = new SecretKeySpec(this.EncryptKey.getBytes(), "AES");
                    cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv));
                    byte[] decrypted = cipher.doFinal(numArray);


                    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
                    SaveData value = objectMapper.readValue(decrypted, SaveData.class);
                    accessToken = value.m_AccessToken;
                    uuid = value.m_UUID;
                    myCode = value.m_MyCode;
                    KRFAM.log("at: " + value.m_AccessToken);
                    KRFAM.log("uu: " + value.m_UUID);
                    KRFAM.log("mc: " + value.m_MyCode);
                }
                KRFAM.log(codeName + " > Updated from A.D File");
                failCheckCount = 0;
            } catch (Exception ex) {
                KRFAM.log(ex);
                KRFAM.log(codeName + " > Failed to Read A.D File - Attempting Fix");
                KRFAM.forcePermission(adFile);
                KRFAM.forcePermission(adFile.getParentFile());
                updateFromADFile(attempt + 1);
            }
        } else {
            KRFAM.log(codeName + " > No A.D File exists");
            uuid = "";
            accessToken = "";
            myCode = "";
        }
    } else {
        uuid = "";
        accessToken = "";
    }
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:81,代码来源:Server.java

示例12: readString

import com.google.common.io.LittleEndianDataInputStream; //导入方法依赖的package包/类
public static String readString(LittleEndianDataInputStream objectInputStream) throws IOException {
    int size = objectInputStream.readInt();
    byte read[] = new byte[size];
    objectInputStream.read(read);
    return new String(read);
}
 
开发者ID:narrowtux,项目名称:SmartModInserter,代码行数:7,代码来源:Util.java


注:本文中的com.google.common.io.LittleEndianDataInputStream.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。