?
Solved

How to get out the byte[] in a ByteArrayDataSource ?

Posted on 2008-11-02
3
Medium Priority
?
434 Views
Last Modified: 2012-05-05
My code looks as follow:

...
com.sun.istack.ByteArrayDataSource byteArrayDataSource = (com.sun.istack.ByteArrayDataSource) erstelleAntragResponse.getPdfDokument().getPdfData().getDataSource();
...

By debugging the byteArrayDataSource looks as follow:

"byteArrayDataSource" = ByteArrayDataSource
  buf=byte[64727]
    [0...99999]
      [0...99]
        [0]=37
        [0]=80
        [0]=68
        [0]=70
        [0]=45
        [0]=49
        [0]=46
...

My question:
1.
How can I get the 'buf'?

2.
The values of "37, 80, 68, 70, 45, 49, 46..." means "%PDF....".

How can I convert it from number to ASCII?
0
Comment
Question by:chenwei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 22862992
Try calling getInputStream on it and writing into a ByeArrayOutputStream (you can find 'IOUtils' at http://www.technojeeves.com/joomla/index.php/free/51-copying-streams ) :
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copyStream(dataSource.getInputStream(), out);
byte[] content = out.toByteArray();

Open in new window

0
 

Author Comment

by:chenwei
ID: 22869027
Hi cehj,

many thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 22869128
:-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question