Hello,
I've a question about DataOutputStream. I'm trying to complete this Pseudo-sentence:
public void writeObjectToFile( DataOutputStream output )
{
< Writing data field values to file. >
}
This is my code:
public void writeObjectToFile( DataOutputStream output )
{
String filename = "test.dta";
try(output = new DataOutputStream(new FileOutputStream(filename)))
{
output.writeUTF(name);
output.writeInt(age);
output.writeUTF(city);
output.writeUTF(country);
}
catch(IOException e3)
{
e3.printStackTrace();
}
}
Whenever I try this, I get this error:
error: <identifier> expected
try(output = new DataOutputStream(new FileOutputStream(filnavn)))
^
Well, I didn't clearly understand this. What did I do wrong?