• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to copy data from n files in a single file  RSS feed

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am giving directory path and trying to copy data of all files in that directory to a file.But, it is writing data of only file.Can anyone tell,how can i copy data of n files in one file.Below is my code :
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean to say it is writing data of only one file in the new file instead of all files.
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m not sure but try to 'flush' everytime you write.
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried flushing but it is still not working
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's related to your problem but you need to put the fileInputStream.close(); inside your while loop. You are only closing the last file you read at the moment.
Also, unless you are practising using while loops this would be much better as a for loop
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!