Java bytearrayoutputstream问题
publicclassDemo4{publicstaticvoidmain(String[]args){try{ByteArrayOutputStreambaos=new...
public class Demo4 {
public static void main(String[] args) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dops = new DataOutputStream(baos);
dops.writeDouble(0.12039120381238123812038);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DataInputStream dips= new DataInputStream(bais);
System.out.println(bais.available());
System.out.println(dips.readDouble());
} catch (Exception e) {
// TODO: handle exception
}
}
}
代码如上,我输出一个double类型的数,再输入的话为什么就少几位 展开
public static void main(String[] args) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dops = new DataOutputStream(baos);
dops.writeDouble(0.12039120381238123812038);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DataInputStream dips= new DataInputStream(bais);
System.out.println(bais.available());
System.out.println(dips.readDouble());
} catch (Exception e) {
// TODO: handle exception
}
}
}
代码如上,我输出一个double类型的数,再输入的话为什么就少几位 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询