Regarding byte arrays

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 30
Reputation: sarath.koiloth is an unknown quantity at this point 
Solved Threads: 0
sarath.koiloth's Avatar
sarath.koiloth sarath.koiloth is offline Offline
Light Poster

Regarding byte arrays

 
0
  #1
Jan 9th, 2008
Friends,

I am stuck here , I am downloading some files from a url uing GZIPInputStream.I need to store this files.So i declared a bytearray with specified length.As i am downloading files with different size, i think i need to declare a dynamic byte array.

Please help me to solve these issue.

Thank You
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,396
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 255
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Regarding byte arrays

 
0
  #2
Jan 9th, 2008
Show your code, so we can better understand what you're talking about. Generally speaking though, you do not need a "dynamic array", you need to use your "static array" properly.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,619
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Regarding byte arrays

 
0
  #3
Jan 9th, 2008
Maybe you need something like this:
  1. InputStream in = zipFile.getInputStream();
  2. OutputStream out = new FileOutputStream(new File("a.bin"));
  3. byte buf[] = new byte[1024 * 8]; /* declare a 8kB buffer */
  4. int len = -1;
  5. while((len = in.read(buf)) != -1) {
  6. out.write(buf, 0, len);
  7. }
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC