It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

Creating a Program that Can Write to a File From User Input

Creating a Program that Can Write to a File From User Input

Postby aaljallaf on Tue Dec 05, 2006 9:38 am

I need to:
Create a Program that Can Write to a File From User Input. Then After a Period of 3 Minutes- The program should display the contents of that file. After Five Minutes it should tell the user to log off.

Things I was told to look for:

user input from the command line
write to a text file

create a timer in java

read a text file and display on the screen

-Do you have any suggestions on how I should get about doing this?

Thank you
aaljallaf
 
Posts: 2
Joined: Mon Dec 04, 2006 7:30 pm

Postby meongmania on Tue Dec 19, 2006 3:54 am

- use input reader, example (for details read java tutorials on I/O) :
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String userInput = input.readLine();

- write using a file stream, example :
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("thefile.txt"));
bos.write(userInput.getBytes());

- extends the class from Thread or implement the Runnable interface (more info, read multithreading in java tutorial). put a sleep status after writing the time.

- use a filestreamreader wrapped in buffer to read the file

- display the content of the stream

- done : )
meongmania
 
Posts: 16
Joined: Tue Dec 19, 2006 2:58 am


Who is online

Users browsing this forum: No registered users and 2 guests