Results 1 to 2 of 2
  1. #1
    blumdiggity is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default writing to text file problem

    Ok I got a client server setup, where the client connects and has to specify if they are a new client or returning client when logging in. If new they enter a username and password which is writen to a txt file after it is checked for duplication. This is where my problem occurs I have a FileWriter the appends the new account info to the end of the text file but it won't write it until the server is stopped.

    My question is, Is there a way to update the txt file while keeping the server running.

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    368
    Rep Power
    5

    Default

    If you don't mind I would ask several questions
    in order to have full picture of what is going on, and after that
    I think we will easily come to solution :)

    So, on sever side thare is this,
    let's call it users.txt file.
    User's usernames and password are stored in it.

    This file is opened for reading when server is up and running and
    waits for client requests in accept().

    First client send username and pass.
    Server has to check it - READING form users.txt happens?

    During that action it might be possible that
    some other user for a first time send his username and pass.
    So while READING, there can be WRITING demand on users.txt ?
    Can we have some conflict here? RandomAccessFile with rw mode? Locking?Multithreading?

    When you close server i guess you call some close block
    where all the streams and file streams are closed.
    Do you use buffers for reading/writing
    and do you have to take care of flushing,
    or you just wait for buffer to become full or wait for close() to do it for you?
    Does this matter anyway?

    some code would help.

    cya later!

Similar Threads

  1. writing to specific line in text file
    By mickmos in forum New To Java
    Replies: 2
    Last Post: 04-18-2009, 01:01 PM
  2. Writing To A Specific Text File Line
    By mokonji in forum New To Java
    Replies: 1
    Last Post: 03-02-2009, 08:13 PM
  3. Replies: 6
    Last Post: 12-12-2008, 03:35 PM
  4. [SOLVED] Writing ArrayList to Text File on seperate Lines
    By shinjitsunohana in forum New To Java
    Replies: 9
    Last Post: 08-27-2008, 05:53 PM
  5. writing text to file
    By notwist in forum New To Java
    Replies: 3
    Last Post: 04-25-2008, 04:20 AM

Posting Permissions

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