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


Java DataOutputStream.writeFloat方法代码示例

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


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

示例1: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream out) throws IOException {
    if (value instanceof String) {
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF((String) value);
    } else if (value instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(((Integer) value).intValue());
    } else if (value instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(((Float) value).floatValue());
    } else if (value instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(((Long) value).longValue());
    } else if (value instanceof Double) {
        out.writeDouble(CONSTANT_DOUBLE);
        out.writeDouble(((Double) value).doubleValue());
    } else {
        throw new InternalError("bogus value entry: " + value);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ProxyGenerator.java

示例2: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Write the constant to the output stream
 */
void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
    if (num instanceof Integer) {
        out.writeByte(CONSTANT_INTEGER);
        out.writeInt(num.intValue());
    } else if (num instanceof Long) {
        out.writeByte(CONSTANT_LONG);
        out.writeLong(num.longValue());
    } else if (num instanceof Float) {
        out.writeByte(CONSTANT_FLOAT);
        out.writeFloat(num.floatValue());
    } else if (num instanceof Double) {
        out.writeByte(CONSTANT_DOUBLE);
        out.writeDouble(num.doubleValue());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:NumberConstantData.java

示例3: savePlayerData

import java.io.DataOutputStream; //导入方法依赖的package包/类
private void savePlayerData(Player player, String saveName) {
	try {
		// open file
		File file = new File(savePath + saveName + "/player/" + player.name + ".data");
		file.getParentFile().mkdirs();
		file.createNewFile();
		DataOutputStream out = new DataOutputStream(new FileOutputStream(file));

		out.write(SAVE_VERSION_PLAYER);

		// save data
		out.writeUTF(player.name);
		out.writeFloat(player.position.x);
		out.writeFloat(player.position.y);
		out.writeFloat(player.position.z);

		out.close();
	} catch (IOException e1) {
		Logger.error("Player data could not be saved!");
	}
}
 
开发者ID:erikgoe,项目名称:Cubeland,代码行数:22,代码来源:SavingSystem.java

示例4: hashCode

import java.io.DataOutputStream; //导入方法依赖的package包/类
public int hashCode(){
	try{
		ByteArrayOutputStream hashbb=new ByteArrayOutputStream();
		DataOutputStream hashb=new DataOutputStream(hashbb);
		Collection<Triangle> tris=triangles;
		for(Triangle tri:tris){
			Vertex vertices[]=tri.vertexes();
			for(Vertex v:vertices){
				hashb.writeFloat(v.pos.x);
				hashb.writeFloat(v.pos.y);
				hashb.writeFloat(v.pos.z);
				hashb.writeFloat(v.uv.x);
				hashb.writeFloat(v.uv.y);
				hashb.writeFloat(v.normal.x);
				hashb.writeFloat(v.normal.y);
				hashb.writeFloat(v.normal.z);
			}			
		}
		hashb.writeUTF(material);
		hashb.flush();
		byte arr[]=hashbb.toByteArray();
		hashb.close();
		return Arrays.hashCode(arr);	
	}catch(Exception e){
		e.printStackTrace();
		return -1;
	}
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:29,代码来源:OBJMesh.java

示例5: send

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void send(DataOutputStream out) throws IOException {
    byte[] packetId = VarData.getVarInt(0x2F);
    byte[] teleportID = VarData.getVarInt(this.teleportID);
    VarData.writeVarInt(out, packetId.length + teleportID.length + 33);
    out.write(packetId);
    out.writeDouble(x);
    out.writeDouble(y);
    out.writeDouble(z);
    out.writeFloat(yaw);
    out.writeFloat(pitch);
    out.writeByte(flags);
    out.write(teleportID);
    out.flush();
}
 
开发者ID:Clout-Team,项目名称:JarCraftinator,代码行数:16,代码来源:PacketPlayOutPlayerPositionAndLook.java

示例6: saveLNetwork

import java.io.DataOutputStream; //导入方法依赖的package包/类
public static void saveLNetwork(String fileName,LNetwork network) throws IOException{
	if(!network.isLearnning()) {
		File file=new File(fileName+".NN");
		file.createNewFile();
		DataOutputStream save=new DataOutputStream(new FileOutputStream(file));
		
		save.writeByte(-127);											//version of .NN
		
		save.writeByte(network.getFunction().getFunctionID());
		
		float[][][] weights=network.getWeights();
		save.writeInt(weights.length);
		
		save.writeInt(network.getInputNumber());
		
		for(int i=0;i<weights.length;i++){
			save.writeInt(weights[i].length);
		}
		for(int i=0;i<weights.length;i++){
			for(int j=0;j<weights[i].length;j++){
				for(int k=0;k<weights[i][j].length;k++){
					save.writeFloat(weights[i][j][k]);
				}
			}
		}
		save.close();
	}
	else throw new NeuralException(3);
}
 
开发者ID:TakMashido,项目名称:Neural-network,代码行数:30,代码来源:FileL.java

示例7: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream output) throws IOException {
    output.writeUTF(getValue().getWorld().getName());
    output.writeDouble(getValue().getX());
    output.writeDouble(getValue().getY());
    output.writeDouble(getValue().getZ());
    output.writeFloat(getValue().getYaw());
    output.writeFloat(getValue().getPitch());
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:10,代码来源:LocationStorage.java

示例8: serialise

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
 public void
 serialise(
 DataOutputStream	os )

 	throws IOException
 {
float[]	data = toFloatArray();

for (int i=0;i<data.length;i++){

  os.writeFloat( data[i] );
}
 }
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:15,代码来源:VivaldiPositionImpl.java

示例9: onWritePacket

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
protected void onWritePacket(DataOutputStream out) throws IOException {
	out.writeUTF(username);
	
	out.writeFloat(targetX);
	out.writeFloat(targetY);
	
	out.writeBoolean(isPrimaryPointer);
}
 
开发者ID:ProjectK47,项目名称:Mafia,代码行数:10,代码来源:PacketSpawnPointer.java

示例10: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Write out the contents of the constant pool, including any additions
 * that have been added.
 */
public void write(DataOutputStream out, Environment env) throws IOException {
    int length = cpool.length;
    if (MoreStuff != null)
        length += MoreStuff.size();
    out.writeShort(length);
    for (int i = 1 ; i < cpool.length; i++) {
        int type = types[i];
        Object x = cpool[i];
        out.writeByte(type);
        switch (type) {
            case CONSTANT_UTF8:
                out.writeUTF((String) x);
                break;
            case CONSTANT_INTEGER:
                out.writeInt(((Number)x).intValue());
                break;
            case CONSTANT_FLOAT:
                out.writeFloat(((Number)x).floatValue());
                break;
            case CONSTANT_LONG:
                out.writeLong(((Number)x).longValue());
                i++;
                break;
            case CONSTANT_DOUBLE:
                out.writeDouble(((Number)x).doubleValue());
                i++;
                break;
            case CONSTANT_CLASS:
            case CONSTANT_STRING:
                out.writeShort(((Number)x).intValue());
                break;
            case CONSTANT_FIELD:
            case CONSTANT_METHOD:
            case CONSTANT_INTERFACEMETHOD:
            case CONSTANT_NAMEANDTYPE: {
                int value = ((Number)x).intValue();
                out.writeShort(value >> 16);
                out.writeShort(value & 0xFFFF);
                break;
            }
            case CONSTANT_METHODHANDLE:
            case CONSTANT_METHODTYPE:
            case CONSTANT_INVOKEDYNAMIC:
                out.write((byte[])x, 0, ((byte[])x).length);
                break;
            default:
                 throw new ClassFormatError("invalid constant type: "
                                               + (int)types[i]);
        }
    }
    for (int i = cpool.length; i < length; i++) {
        String string = (String)(MoreStuff.elementAt(i - cpool.length));
        out.writeByte(CONSTANT_UTF8);
        out.writeUTF(string);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:61,代码来源:BinaryConstantPool.java

示例11: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream stream) throws IOException{
	stream.writeFloat(power);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:5,代码来源:PowerBlock.java

示例12: stream

import java.io.DataOutputStream; //导入方法依赖的package包/类
public static void stream(Vector3 vector3, DataOutputStream dataOutputStream) throws IOException {
  dataOutputStream.writeFloat(vector3.x);
  dataOutputStream.writeFloat(vector3.y);
  dataOutputStream.writeFloat(vector3.z);
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:6,代码来源:VectorUtil.java

示例13: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream out, Object o) throws IOException
{
	out.writeFloat((Float) o);
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:5,代码来源:TagType.java

示例14: write

import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream output) throws IOException {
    output.writeFloat(value);
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:5,代码来源:FloatStorage.java

示例15: stream

import java.io.DataOutputStream; //导入方法依赖的package包/类
public static void stream(Vector3 vector3, DataOutputStream dataOutputStream) throws IOException {
	dataOutputStream.writeFloat(vector3.x);
	dataOutputStream.writeFloat(vector3.y);
	dataOutputStream.writeFloat(vector3.z);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:6,代码来源:VectorUtil.java


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