Two Laptop Bag*
The moose likes Beginning Java and the fly likes byte array of byte arrays. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "byte array of byte arrays." Watch "byte array of byte arrays." New topic

byte array of byte arrays.

cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77

How to declare and access the byte array of byte arrays. Any tutorials really appreciated.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

// This is an array of twenty ten-byte arrays.
byte[][] bytes = new byte[20][10];

[Jess in Action][AskingGoodQuestions]
cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77

I want to store the byte array values I am getting, each time I iterate through the for loop. could you please tell me how can i store the byte array into an another array and after storing going to the next iteration in the for loop to get the another.

Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

The Java� Tutorial - Arrays of Arrays
cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77

byte[][] b = new byte[5][];

for(int i = 0;i<doc.getPageCount();i++){
CMBPage page = doc.getPages(0);
int a = doc.getPageCount();
b[i] = baos.toByteArray();// 1
Is statement 1 is right. If not how to update it. please help me.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
1. You arbitrarily create b with a length of 5 but then loop with a upper bound of doc.getPageCount().
2. I have not idea what doc or CMBPage are, but why do you only access page 0, not page i?
3. Why do you define a?
4. Where is baos defined? you call toByteArray repeatedly. Does the other code in the loop
have some side effect on what toByteArray returns?

There is no emoticon for what I am feeling!
subject: byte array of byte arrays.
Similar Threads
Array reference assignment
Serializing a ByteArrayOutputStream
Doubt About the output of this Question
What's the difference in this case? (so basic)
javax.mail attachment not correctly encoded