This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Create a files with training timestamp postfix  RSS feed

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to create 3 files, each one minute apart, and all of them having the future minutes postfixed to them, likde:

testInvertDatePattern.log.31-12-1969-19-00

testInvertDatePattern.log.31-12-1969-19-01

testInvertDatePattern.log.31-12-1969-19-02

and also write "Hello" to each file, and locks it after writing data.

Can anyone, please give me some clue?

Thanks,
-Kamal.
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get the date and time try looking at java.util.GregorianCalendar



To write a file look at java.io tutorial.

Java IO Tutorial

Jason.
[ March 13, 2006: Message edited by: Jason Moors ]
 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason,
Thanks for the tip:
Now here is what I did: Since i want a CUSTOM Date Postfix:

I declared a UniqueFileStrategy class which is an inner class:



and another inner class , which uses the UniqueFileStrategy class:



and then call the overlappingRollovers(boolean readOnly) with true and false cases:

as:
public void testOverlappingRollovers() throws IOException {
overlappingRollovers(false);
}
public void testOverlappingRolloversReadOnly() throws IOException {
overlappingRollovers(true);
}
 
author
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think , to lock files you have to use the java.nio.* package. Correct me if I am wrong.
 
Goodbye moon men. Hello tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!