Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to split file after it retched to defind size?  RSS feed

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

im creating simple log file with :

msgOutputStream = new PrintWriter(new FileWriter(msgLogFile, true), true);

msgOutputStream.println(new Date() + "\t" + someTestVar);

how can i detect that the file im writing to is reached for example to 5 mega and now i like to close it and open new file with extension of "_1"to write to ?
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried with java.io.File.length()?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can funnel all the writes through one method that keeps track of length ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!