Results 1 to 2 of 2
Thread: writing to text file problem
- 02-26-2010, 07:37 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 2
- Rep Power
- 0
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.
- 02-26-2010, 03:43 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 366
- Rep Power
- 12
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
-
writing to specific line in text file
By mickmos in forum New To JavaReplies: 2Last Post: 04-18-2009, 02:01 PM -
Writing To A Specific Text File Line
By mokonji in forum New To JavaReplies: 1Last Post: 03-02-2009, 09:13 PM -
Reading and writing the contents of jtable into a text file
By Manfizy in forum NetBeansReplies: 6Last Post: 12-12-2008, 04:35 PM -
[SOLVED] Writing ArrayList to Text File on seperate Lines
By shinjitsunohana in forum New To JavaReplies: 9Last Post: 08-27-2008, 06:53 PM -
writing text to file
By notwist in forum New To JavaReplies: 3Last Post: 04-25-2008, 05:20 AM
Bookmarks