File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes add timestamp with .txt file  & write some information to the .txt file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "add timestamp with .txt file  & write some information to the .txt file" Watch "add timestamp with .txt file  & write some information to the .txt file" New topic
Author

add timestamp with .txt file & write some information to the .txt file

kan ashok
Greenhorn

Joined: Feb 28, 2004
Posts: 8
I created one directory and put .txt file thru runtime. That works fine.
a). How can i add timestamp with .txt file while creating the .txt file
b). How can i write some information (or) values within the .txt file
thru my java program
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the I/O and Streams forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Do you mean you want to add a timestamp to the content of the file, or to the name of the file? (I.E. logFile03312004.txt)
kan ashok
Greenhorn

Joined: Feb 28, 2004
Posts: 8
I want to add timestamp with the name of the .txt file. (ie logFile03312004.txt)
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
If you are making a new file and nameing it, try this:

If you have an exisitng file, try this with above code to rename it, assuming that existing file (of type java.io.File) is called "theFile" in the code below:

Hope this helps!
[ March 15, 2004: Message edited by: Kim Kantola ]
[ March 15, 2004: Message edited by: Kim Kantola ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add timestamp with .txt file & write some information to the .txt file
 
Similar Threads
Help needed to compare timestamp
directory creation thru java program
append a file name with timestamp
My Design Choices!
Need to write some information to stderr in Java on UNiX