Solved

How to create a file in java by appending file chunks together

Posted on 2008-10-03
2
549 Views
Last Modified: 2012-06-21
Hi I have a SOAP Message which returns the following schema (parts are starred out for security purposes) :

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <DownloadZipChunkResponse xmlns="http://***.***.gov.uk/***">
      <DownloadZipChunkResult>base64binary</DownloadZipChunkResult>
    </DownloadZipChunkResponse>
  </soap12:Body>
</soap12:Envelope>

The 'base64binary' part of that is a chunk of a file.  The way my program works is that I query the web service with a soap message, sending it the chunk size and the offset so that it know what chunk and size of chunk to send back.

Once I parse the chunk out of the response, I am not sure how I append all of these chunks together to make the overall file.  No idea if I should be using FileStream or any sort of stream or how to write to a location on my machine.

Any help would be much appreciated
0
Comment
Question by:moorcroftlad
[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 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 500 total points
ID: 22635057
Assuming your program is authorized to write a file onto your machine (which it will be if it is an application; if it is an applet it will need additional authority), you can do it with a file stream.

FileOutputStream fo=new FileOutputStream(filename);
fo.write(b);
...
...
//and, eventually
fo.close();


where filename is a String that is a path to a file and b is a array of bytes. There are other possibilities for which you can see the documentation. Most of those calls need to be covered by a try/catch for IOExceptions as well.

If you have any questions, please ask.
0
 

Author Comment

by:moorcroftlad
ID: 22648070
Cheers thats what I needed to know
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

623 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