本文整理汇总了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);
}
}
示例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());
}
}
示例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!");
}
}
示例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;
}
}
示例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();
}
示例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);
}
示例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());
}
示例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] );
}
}
示例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);
}
示例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);
}
}
示例11: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream stream) throws IOException{
stream.writeFloat(power);
}
示例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);
}
示例13: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
public void write(DataOutputStream out, Object o) throws IOException
{
out.writeFloat((Float) o);
}
示例14: write
import java.io.DataOutputStream; //导入方法依赖的package包/类
@Override
public void write(DataOutputStream output) throws IOException {
output.writeFloat(value);
}
示例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);
}