This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
kan ashok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum...
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add timestamp with the name of the .txt file. (ie logFile03312004.txt)
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic