Reputation: 1169
This is some basic java code:
package javaapplication32;
import java.io.*;
public class JavaApplication32 {
public static void main(String[] args)throws Exception {
try{
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("dec.dat")));
in = new DataInputStream(new BufferedInputStream(new FileInputStream("enc.dat")));
String enc=in.readUTF();
System.out.println(enc);
}catch(EOFException e){
}
}
}
I am getting the error that it cannot find the symbol 'in' or 'out'
Upvotes: 2
Views: 352
Reputation: 123
In Java, Pre Initialisation of strings is mandatory. Only then you can use them inside a program. Easiest way to do this is:
String in="";
String out="";
You should be fine...
Upvotes: -3
Reputation: 376
You need to declare in and out as something first!
DataInputStream in =
DataOutputStream out =
E.g.
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("dec.dat")));
in = new DataInputStream(new BufferedInputStream(new FileInputStream("enc.dat")));
Upvotes: 0
Reputation: 2311
This should work.
package javaapplication32;
import java.io.*;
public class JavaApplication32 {
public static void main(String[] args)throws Exception {
try {
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("dec.dat")));
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("enc.dat")));
String enc=in.readUTF();
System.out.println(enc);
} catch(EOFException e) {
}
}
}
Upvotes: 2
Reputation: 3115
You should declare them first.
public static void main(String[] args)throws Exception {
DataOutputStream out = null;
DataInputStream in = null;
try{
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("dec.dat")));
in = new DataInputStream(new BufferedInputStream(new FileInputStream("enc.dat")));
String enc=in.readUTF();
System.out.println(enc);
}catch(EOFException e){
}
}
Upvotes: 7
Reputation: 1349
You have not actually declared anything as in
or out
.
DataInputStream in =
DataOutputStream out =
Upvotes: 3
Reputation: 312249
In order to define variables you must give them types, e.g.:
OutpustStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("dec.dat")));
InputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("enc.dat")));
Upvotes: 6