Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

need help with files input

  Asked By: Jada    Date: Mar 10    Category: Java    Views: 513
  

public void saveData()
{
File file;
ObjectOutputStream oos;
FileOutputStream fos;
boolean b;

file = new File("info.dat");
if(file.exists())
b = file.delete();
file = new File("info.dat");
try
{
fos = new FileOutputStream(file);
oos = new ObjectOutputStream(fos);
if(fos != null && oos != null && unit!= null && arr.length != 0)
{
for(int i = 0; i < arr.length; i++)
{
oos.writeObject(arr);
}
oos.flush();
fos.close();
oos.close();
}
}
catch(IOException e)
{
System.out.println(e.getMessage()+ "!!!");
}
}

i have an array of type Unit, which is arr. i want to write the
contents of this array into the binary file info.dat. is this ok?
because when i run the program, it doesn't write it, it goes to the
catch. anyone?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on need help with files input Or get search suggestion and latest updates.




Tagged: