Hi all,
I found out how to save an object using Serializable in JAVA, the standard
Code:
try
{
String filename = "yep";
FileOutputStream fs = new FileOutputStream( filename );
ObjectOutputStream os = new ObjectOutputStream( fs );
os.writeObject( MyProgramList.MainVariableList );
os.close();
}
catch( Exception ex)
{
ex.printStackTrace();
}
however how can I set up my MainVariableList to have a function/method saveobject so it saves the object within it's own class, the below code compiles, however when I run it reports an error on startup but works, basically what do I use for the red line, how do I tell it what object is passed to the class? Thanks all
Code:
public class GameTextData implements Serializable {
//fields
private String namestr;
blah ....
//methods
public void saveobject()
{
try
{
String filename = "yep";
FileOutputStream fs = new FileOutputStream( filename );
ObjectOutputStream os = new ObjectOutputStream( fs );
os.writeObject( MyProgramList.MainVariableList );
os.close();
return( true );
}
catch( Exception ex)
{
ex.printStackTrace();
return( false );
}
}