자바로 바이너리 파일을 만들어야 하는데 쓰는게 정수만 들어가더라구요 실수형을 바이너리 파일로 만들 수 없나요??
for(int i = 1; i<=10; i++){
out.write(2.5841965448717623);
}
이 부분이 문제인데 실수형이 안들어가서요.. 실수형으로는 바이너리 파일로 못쓰나요?
package tts_test;
import java.io.*;
public class a
{
public static void main(String [] args)
{
try{
String filename = "D:/test.dat";
FileOutputStream out = new FileOutputStream(filename);
FileInputStream File = new FileInputStream(filename);
InputStreamReader in = new InputStreamReader(File);
for(int i = 1; i<=10; i++){
out.write(2.5841965448717623); // 이 부분이 컴파일 에러.
}
int c;
String str = new String();
while((c=in.read()) != -1){
//System.out.print(c + " ");
str = str + c;
}
System.out.println(str);
in.close();
out.close();
}catch(IOException ie){
System.out.println("파일이 존재하지 않습니다.");
}catch(Exception e){
System.out.println(e);
}
}
}