Answer the question
In order to leave comments, you need to log in
What encoding do DataOutputStream and DataInputStream work with?
What encoding do DataOutputStream and DataInputStream work with? For example:
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Soltuion {
public static void main(String[] args) throws IOException {
// Как записывает true:
// записали:
DataOutputStream fileOutput = new DataOutputStream(new FileOutputStream("C:\\testjava.txt"));
fileOutput.writeBoolean(true);
// читаем:
FileInputStream fileStream = new FileInputStream("C:\\testjava.txt");
System.out.println(fileStream.read()); // 1
// Как записывает double:
// записали:
fileOutput.writeDouble(3.2);
// читаем:
System.out.println(fileStream.read()); // 64
System.out.println(fileStream.read()); // 9
System.out.println(fileStream.read()); // 153
System.out.println(fileStream.read()); // 153
System.out.println(fileStream.read()); // 153
System.out.println(fileStream.read()); // 153
System.out.println(fileStream.read()); // 153
System.out.println(fileStream.read()); // 154
System.out.println(fileStream.read()); // -1
}
}
Answer the question
In order to leave comments, you need to log in
DataOutputStream and DataInputStream work with their own special encoding, which can be found in the sources. This allows you to store a boolean value in 1 byte, etc.
Obvious persons in notepad cannot read this, because notepad does not know the above encoding. Can be read through DataInputStream.
In such variant - in any coding. You write pure pristine bytes there, they are not converted in any way. Then you read these bytes one by one.
https://docs.oracle.com/javase/7/docs/api/java/io/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question