String path = "E:\\1.txt";
File file = new File(path);
FileInputStream fis = null;
DataInputStream dis = null;
try {
fis = new FileInputStream(file);
dis = new DataInputStream(fis);
Float num;
num = dis.readFloat();
System.out.println(num);
文件 内容就是1.1
但是输出却是2.5348215E-9请问这是怎么回事啊?
谢谢了啊
public static void main(String[] args) throws IOException {
String path = "E:\\1.txt";
File file = new File(path); BufferedReader reader = new BufferedReader(new FileReader(file));
try {
String line = reader.readLine();
System.out.println(line);
} finally {
reader.close();
}
}
28.7812 34.6 34.56 45.8954
我怎么读成float啊?
谢谢了啊
麻烦了
基础还是要看的
但你的文本内容的读取不一定都是字节,有时事字符。如果你的文本中有一个中文的话,那么用字节流去处理的时候就会出错