+ 1
Why don't Data Input Stream work in Sololearn??
I know I can use Scanner class to input data as an alternative but I am curious why don't Data Input Stream work here??
5 ответов
+ 1
DataInputStream() works on sololearn, try this:
import java.io.*;
class DataInputStreamDemo {
public static void main(String args[]) throws IOException {
DataOutputStream out =
new DataOutputStream( new FileOutputStream("file.dat"));
DataInputStream in =
new DataInputStream( new FileInputStream( "file.dat"));
out.writeInt(123456);
int num = in.readInt();
System.out.println("data from input stream: " +num);
}
}
+ 1
zemiak I mean it doesn't work for taking input from user as scanner does
+ 1
Saksham Jain The Scanner is the Java equivalent of taking input from the shell.
0
I think you refer to Stdin?
This is because we don't have a shell, but a sandboxed environment, which prevents most intrusions through vulnerabilities
0
Loeschzwerg What's the difference in working of Scanner and Data Input Stream?