freelanceprogrammers.org Forum Index » Java

File Input


View user's profile Post To page top
rockcharlize Posted: Fri Apr 09, 2004 9:54 pm


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?
Reply with quote
Send private message
View user's profile Post To page top
nitrusrit Posted: Sat Apr 10, 2004 5:57 pm


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]
Reply with quote
Send private message
View user's profile Post To page top
rockcharlize Posted: Sun Apr 11, 2004 6:35 pm


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]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

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
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