Solved

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

Posted on 2008-10-03
2
543 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

738 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