當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。