我在两个文件中有浮点数。我想将它们写入单个文件。写入后打开文件时,看不到浮点数。我可以看到一些机器代码或其他东西。这是我的代码
import java.io.*;
import java.util.*;
public class F
{
public static void main(String args[]) throws Exception
{
FileInputStream fr1 = new FileInputStream("distance.txt");
BufferedReader br1 = new BufferedReader(new InputStreamReader(fr1));
FileInputStream fr2 = new FileInputStream("price.txt");
BufferedReader br2 = new BufferedReader(new InputStreamReader(fr2));
FileOutputStream fw1 = new FileOutputStream("file1.txt");
BufferedOutputStream bos=new BufferedOutputStream(fw1);
DataOutputStream dos=new DataOutputStream(bos);
String s1,s2;
while(((s1 = br1.readLine()) != null) && ((s2=br2.readLine())!=null))
{
float a1=Float.parseFloat(s1);
float a2=Float.parseFloat(s2);
a1=a1*10;
a2=a2*10000;
System.out.println(a1+" "+a2);
dos.writeFloat(a1);
dos.writeFloat(a2);
}
}
}