tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clive De Silva" <>
Subject saving and opening files
Date Mon, 13 Jan 2003 23:48:24 GMT
Hi, I have placed my package in the \Apache Group\Tomcat 4.1\common\classes\ folder and they
are all standard Java classes [no servlets or jsps]. One of the methods invoked in my main
class serializes an object and saves it to a persistent file at runtime :

---------------------Start Snip 1-----------------------
  public boolean saveUser(){
    File file2 = new"states.gip");
        FileOutputStream out2 = new FileOutputStream(file2);
        ObjectOutputStream s2 = new ObjectOutputStream(out2);
        System.out.println("You have save successfully");
        return true;
      catch(Exception e){
        System.out.println("You have save UN-Successfully");
        return false;
---------------------End Snip 1-----------------------

When the class is initialised/created, it first checks to see if there is a file called states.gip
and if there is, then it reads in the object, if there isnt, then it creates an object and
at a latter stage saves it:

---------------------Start Snip 2-----------------------
  public boolean createUser(String name){
    try{//see if a user had been created and try to load it back
      File file2 = new"states.gip");
      FileInputStream in = new FileInputStream(file2);
      ObjectInputStream s1 = new ObjectInputStream(in);
      myUser = (MainUser)s1.readObject();
      user = recommenderEPG.addUser(name);
      user = myUser.unallocate(user);
      System.out.println("There was an old user!");
      return true;
    catch(Exception e){//user has not been created so an exception is thrown -going to create
a new user
        myUser = new MainUser(name);
        user = recommenderEPG.addUser(name);
        System.out.println("there is definitely no old user");
        return true;
      catch (DataNotFoundException ef){
        return false;
---------------------End Snip 2-----------------------
When the class does get created for the first time, it does not see the 'states.gip' file,
which is correct, because it has not been created yet. If it is instantiated for a second
or nth time, it always sees the file and loads it correctly. My Question is: where is this
file stored? I can not find a physical trace of this file - i have done search after search
and it is not there - yet the Java class opens it correcly!!!!! Help!



Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.435 / Virus Database: 244 - Release Date: 30/12/2002

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message