Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: write & read/load to/from file

    Now we're getting somewhere.
    That's a handle on the remote object.
    Which is not surprising.

    Where is your naming server?
    Presumably on the machine this code is running?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  2. #22
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: write & read/load to/from file

    Also posted at (with code): Java Bank, rmi & eclipse
    If you don't understand my response, don't ignore it, ask a question.

  3. #23
    schvuu is offline Member
    Join Date
    Oct 2013
    Posts
    15
    Rep Power
    0

    Default Re: write & read/load to/from file

    Quote Originally Posted by Tolls View Post
    Now we're getting somewhere.
    That's a handle on the remote object.
    Which is not surprising.

    Where is your naming server?
    Presumably on the machine this code is running?
    The 'Naming is just an import -> import java.rmi.Naming;

  4. #24
    schvuu is offline Member
    Join Date
    Oct 2013
    Posts
    15
    Rep Power
    0

    Default Re: write & read/load to/from file

    It's not problem guys, I fixed my problem!
    I serialized and wrote an array list to file, the arraylist had the Accounts in them, then when I read it back, I did not work.. no surprise there.. but I wrote this:

    Java Code:
    	 ObjectInputStream fileIn = new ObjectInputStream(new FileInputStream("file"));
    	 accounts = (ArrayList<AccountServer>) fileIn.readObject();
    	 for (AccountServer i : accounts){
    	    	AccountServer newAcc = new AccountServer();
    	    	String nameAcc = i.getName();
    	    	Integer passAcc = i.getPassword();
    	    	Integer balanceAcc = i.getBalance();
    	    	Integer numAcc = i.getNumber();
    	    	
    	        Naming.rebind(nameAcc, newAcc);
    	        newAcc.setName(nameAcc);
    	        newAcc.setPassword(passAcc);
    	        newAcc.setBalance(balanceAcc);
    	        newAcc.setNumber(numAcc);
    	 }
    	 fileIn.close();
    
        }
    And then it worked, so basicly I re-created the accounts, well well, thanks for taking an interest!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. read/write file
    By akl in forum New To Java
    Replies: 5
    Last Post: 07-14-2013, 08:53 PM
  2. Replies: 8
    Last Post: 07-25-2012, 10:00 AM
  3. Replies: 0
    Last Post: 07-25-2011, 05:16 PM
  4. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  5. Read and Write file
    By mrdestroy in forum New To Java
    Replies: 13
    Last Post: 10-31-2008, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •