File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Vector of byte arrays - how to get my data out? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vector of byte arrays - how to get my data out?" Watch "Vector of byte arrays - how to get my data out?" New topic
Author

Vector of byte arrays - how to get my data out?

Ichiro Takeshita
Greenhorn

Joined: May 29, 2007
Posts: 9
Hi,

This is my first post here at Java Ranch. I'm wondering if someone can educate me.

I have a vector (fileDataList). Within a loop I am adding arrays of bytes (the return value from readFile(filename)) thus:




As you can see from the second line of the example above I am comfortable with casting object back to their original type when reading them from a vector.

But how do I get my byte arrays back out of the fileDataList? What cast can I use? The code below won't work because we can't convert from Object to byte[]



Is there a simple answer?

I.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,

Welcome to JavaRanch!

"data = (byte[]) fileDataList.elementAt(i)" would work just fine.


[Jess in Action][AskingGoodQuestions]
Ichiro Takeshita
Greenhorn

Joined: May 29, 2007
Posts: 9
Ernest,

Thanks for such a fast reply.

As an experienced programmer, yet Java beginner I often find myself able to write some amazing code in no time at all, only to be stumped for eternity on a simple problem such as this.

Thanks for saving me from further frustration.

I.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector of byte arrays - how to get my data out?