freelanceprogrammers.org Forum Index » Java
File Input
Joined: 09 Apr 2004
Posts: 2
File Input
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?
Joined: 10 Apr 2004
Posts: 19
File Input
Is your class Unit serializable?
Dustin
rockcharlize <rockcharlize@...> wrote:
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?
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
[Non-text portions of this message have been removed]
Joined: 09 Apr 2004
Posts: 2
File Input
it is now. i figured it out. thanks anyway peace out
Dustin Metzgar <dustin_metzgar@...> wrote:Is your class Unit serializable?
Dustin
rockcharlize <rockcharlize@...> wrote:
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?
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
[Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/
To unsubscribe from this group, send an email to:
beginnersclub-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







