• Post Reply Bookmark Topic Watch Topic
  • New Topic

strreams 4 massive file?  RSS feed

 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello buddies,

Which Interface(Streams) is best to handle very big document file(Ex:- .doc file of size 50MB)?

thanks,

regards,
Mahesh P
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you want to do with it. If you don't need to read the whole thing at a time then look at RandomAccessFile which allows you to jump in at a particular byte offset and start reading. I use this on very large files (GB's) to read small sections st a time.
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Mr. Wood, what if i want to just open the file and display the output or just copy the contents to other files?

thanks 4 ur reply.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then I guess you would need to look at something like FileInputStream which shouldn't have a problem reading a large file...the limitation will be how much of that file you need to keep in memory to do something with it. A stream itself should not use the memory up as it reads. What sort of file are you trying to read - ASCII or binary?
 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tell me in both situations.like if i want to use both ascii and binary formats(source codes in two java files).
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then for the ASCII file consider using java.io.FileReader, which reads in a line at a time as a String and is easy to use. I tend to use along with BufferedReader something like this...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!