• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing Large Data to Auto Generated Data Files

 
Drew Meyers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be running a program that will generate a large amount of data. Is there a way to set a limit for after x amount of records to write the data to a specific data file, then when the x amount is reached again to write it to the same data file with a progressive number added to the end of the data file name but before the period?
EX: test.txt (first time x amount is reached)
test1.txt (second time x amount is reached)
and so on until all of the data is produced and written?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Drew,
Welcome to the Ranch.

If your application is the one generating the data being dumped to the file, you can keep a track of the length/limit and switch files when required. Where exactly are you stuck?
 
Drew Meyers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, it is a program that I have written. Where I'm stuck is I only know how to write to a specific data file. How does one increment the file name? Since the outputted file name is in quotes "test.txt", how do you insert the increment into it? Or is there a better way to do this?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maintain a count. Use loops. Insert the number where required using String.valueOf(count)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!