Download and save half way though

If I have only downloaded a file half way through (ie I restarted the computer before it had finished) and then I want to restart it downloading half way in the file, so I don't have to totally restart it. This is what I have done so far to download a file:
try {
URL url = nextSpace.getUrl(sn); // Gets Url
fileName = nextSpace.getFileName(sn); // Gets Name
FileOutputStream fileoutputstream1 = new FileOutputStream(fileName);
int character;
URLConnection urlconnection = url.openConnection();
InputStream in = urlconnection.getInputStream();
while((character = in.read()) != -1) {
fileoutputstream1.write((char) character);
fileoutputstream1.close();
in.close();
} catch (Exception e) {}
I've slightly modified it so there is less code. I know how to start downloading from a certain place with this:
urlconnection.setRequestProperty("Range","bytes=fileName.length()-urlconnection.getContentLength()");
But how do I save what I've download to the correct place in the file??? And also if it is possible to save into the file 10 or so bytes in (over writing some data), so just in case the data at the end of the file was damaged when the connect was brocken.
So to sum it up, how do I write to a file so far in??
Thanks for your help again
Ben Black

check out java.io.RandomAccessFile
Be careful when using Range header, the server may send the whole content rather than the specified range of bytes. check the response code. 206 implies the server is sending partial content, as you requested.
Hope it helps.

Similar Messages

  • I was now downloading Mt. Lion on my macbookpro and about half way through it gave an error message for the second time. It won't restart!!!! Help???

    I am trying to download Mt. Lion on my macbookpro and about half way through it gives me an " an error has occured" message. This is the second time!!. How do I restart the down load??? Normal app store route does not work???? or get a cd..

    3194
    See the actions for that error here:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    iPhone Error 3194 - How to Fix iTunes Error 3194?
    Fix Error 3194 from iTunes during iPhone restore

  • I received a photo attachment in a gmail and my iphone 4 doesn't seem to have a single option to download and save it to the phone. there has to be a way no?

    i received a photo attachment in a gmail and my iphone 4 doesn't seem to have a single option to download and save it to the phone. there has to be a way no?

    Tap the image and you can select "Save Image" or "Copy".

  • Flash Player update 10.3 unable to download and save flv files

    Hello,
    Since the Flash Player update to 10.3.183.10 it is no longer possible for me to download and save *.flv files. A file of only 2320 kb is saved along with a meta file of 1 kb. The 2320 kb file has a flv extension but the file will not play in any of my media players. Files of mp4 type still download and play fine. The problem only occurred following the last upgrade and even though I uninstalled then reinstalled Adobe Flash Player I cannot overcome the problem. My PC runs MS Windows Vista Home Premium Version: 6.0.6002 Service Pack 2 Build 6002. Browser Internet Explorer 9.0.8112.16421.
    Your assistance would be much appreciated.
    Dibloc

    Thank you.
    The problem only occurs when downloading flv files from YouTube. For all video downloads I have been using RealPlayer and experience no problems when downloading flv files from sites other than YouTube.
    Have been able to download these files now using the site http://www.savevid.com/
    Perhaps YouTube are blocking the use of RealPlayer from downloading flv files?

  • How do I download and save my Free Press e-Edition?

    My e-Edition of the Detroit Free Press opens automatically once I'm logged in.  I want to be able to download and save it, but the way it opens doesn't give me those options.  Therefore, if I'm not in an area with WiFi, I can't read the paper.  I want to be able to download and save it sol, when I'm at my friend's house (he's blind), I can read the paper to him.  thanks.

    Late note:
    It may work with earlier versions of Firefox, or it may be updated at some point, but it's not working with the current version of Firefox as I post this.

  • HT201413 done download update but half way stop then my iphone not working

    connect to pc and start download update as half way error then my iphone not working to start up

    you might want to attempt backing up the device to iTunes and then restoring again.
    http://support.apple.com/kb/HT1766
    maybe even place the device in recovery mode and then restore again as a last resort.
    http://support.apple.com/kb/HT1808

  • Movie streams and about half way through it wont stream anymore

    I open a movie on my external hard drive and the movie begins to play via airplay to the apple tv2.  About half way though the movie, the streaming locks up and can't finish watching the movie.  Any help would be appreciated.
    Apple TV 2, iMac 8GB 1067 MHz DDR3, 3.06 GHz Intel Core 2 Duo

    Welcome to the Apple Community.
    Select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History on your computer.

  • Using AMP to download and save FLV files from web sites?

    I thought I had heard months ago that this new media player was going to allow you to download and save the FLV files from web sites like YouTube and others, where a direct download while possible, isn't the easiest thing to currently do. But I don't really see any way in this new media player to download and save files from web sites....it's plenty willing to play them if they're already saved on your hard drive, but I thought one of the reasons for Adobe building this was to make it easier to get them in the first place?

    I'd have to agree. This is one of the most useless products I have seen from a company of this standard. Why they continue to provide this product as an example of what can be done with AIR, is bewildering.  Myself and others have posted over and over again that the player deletes the saved movies at some random time, an hour or two hours after they appear to be saved.
    What is the point of having a 'saved' icon the CD ICON if that movie will be deleted   FOR NO BLOODY reason.  I just wasted 400 mb of my quota dowloading moves 3 times...!! just to realise that the application deletes them from the VERY CACHE that it copies them to.
    Adobe, if this is what I can expect while trying to view the tutorials for FLEX what will the development experience be like. Myself and others are fed up with posting this bug to Adobe, just to be ignored. How much stress to do you want on your servers before you WAKE UP.
    I have been in 4 meetings over the last 2 weeks and everyone has remarked about the 'experience' trying to view these tutorials.
    Wake up to yourself. If you want to charge $500 for FLEX then atleast fix this crappy player.
    PS. I note that this player is supposedly built with Flex and that the list control truncates rather than wraps, in addition, no 'tool tips',  dates are not localised, the video keeps unpausing itself each time I return from the downloads page, no settings for where files should be cached. Occasionally the underlining (grey) window bar appears over the top of the flash window edge.  I've used the application for an hour or so...
    Where is the alternative... I'll be glad when Adobe get some real competition.. so that they pay attention to input.  A big wastefull site if all support does is read and ignore posts.!!!!!!!!!!!!

  • I recently updated my macbook, i don't know if that has any effect to my recent problem, but when i try to download and save .mp3 files from the internet, like i have done in the past, it downloads but not as an mp3 file, its "blank"

    i recently updated my macbook, i don't know if that has any effect to my recent problem, but when i try to download and save .mp3 files from the internet, like i have done in the past, it downloads but not as an mp3 file, its "blank" and when i try to open it, i can't? I NEED HELP !

    Here is the download page

  • I was updating my iphone 5 and stopped half way .what do i do

    updating my iphone 5 and stopped half way .what do i do

    Hold down the home button and the on/off switch until the Apple logo
    appears. Ignore the red power off slider if it appears.

  • How do I download and saves html files off my website to store and save using Dreamweaver CS3?

    How do I download and saves html files off my website to store and save using Dreamweaver CS3?
    I need to save all files from web and store onto a drive to reupload to a new domain name.  I use Dreamweaver CS3.

    First define your Local Site folder in Dreamweaver.  DW will use this folder to store your site files.
    Go to Manage Sites > New or Edit site.  See screenshots.
    Servers:  Enter your remote server's log-in details.  When complete, hit TEST to see if the connection is working.  If all is well, hit SAVE.
    From the Files Panel (F8), click on Remote Server to show the files that are currently there.  Click the green Down Arrow to GET files from remote server to your local site folder.
    Nancy O.

  • Whenever I try to download a PDF to save for future use, it keeps opening up the text in my email and won't give me the option to download and save.  Any suggestions?

    whenever I try to save a PDF document on mu iPad, it will only open up as text in my email and won't give me an option to download and save.  Any suggestions?

    You can hold down on the open PDF and get the option to Open In -  in the resulting pop up window.

  • Due to a slow ISP I would like to download and save tutorials on my hard drive, is this possible?

    hI, I would like to download and save tutorials on my hard drive is this possible and ow do I do it?
    My ISP Is very slow and Adobe TV does not work. 30 minutes tryingto open a single tutorial and nothing.

    Not with iPhoto.
    You can relocate the masters using Aperture if you're using the latest versions of both iPhoto and Aperture. However, if you're planning on using iPhoto going forward having the masters on one disk and the Library on another is not a good idea. Have a read of this
    https://discussions.apple.com/thread/3062728?tstart=0

  • Download and save files or Office files!

    How can I download and save an EXE file or Office files i.e. DOC, XLS or PPT files to iPhone 5 and then transfer them to Computer/Laptop?
    Thanks
    Shahzad Zameer

    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox.<br />
    Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    See also "Disable virus scanning in Firefox preferences - Windows"
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • HT3281 Podcasts- can't download and save any more

    Suddenly, I can no longer download and save a podcast. I always had a download button for a podcast and now all I have is down arrrow button that streams the podcast, which isn't helpful. What happened? I don't believe I changed anything.

    I have not seen this error before but this person made a video how to troubleshoot it: [https://www.youtube.com/watch?v=Nyp40p0FZzI]

Maybe you are looking for

  • Performance Issues with crystal reports 11 - Critical

    Post Author: DJ Gaba CA Forum: Exporting I have migrated from crystal reports version 8 to version 11. I am experiencing some performance issues with reports when displayed in version 11 Reports that was taking 2 seconds in version 8 is now taking 4-

  • Help with SQL

    Hi Gurus, I am working on a report where i created a view. This query pulls data from SO,PO,ITEMS,AP and AR tables. The problem I am having is when I add a AP tables or a field from that table some of the Order Numbers are disappearing. Could someone

  • Building a dll with labview for CVI

    Hi, I am making some abstract hardware layers for some instruments and i use to work with Labwindows CVI. But i have found ONE instrument, the Instek pst3201 alimentation which is ONLY created with Labview. So i downloaded the 8.6 LV demo and builded

  • Where is the NullPointerException coming from?

    The program in question uses the following typical and generic code to set the LAF of the program to that closest to the original OS. //Set look and feel.     String nativeLookAndFeel = UIManager.getSystemLookAndFeelClassName();     try       UIManag

  • Where is the "variations" feature in photoshop for adjusting color?

    where is the "variations" feature in photoshop for adjusting color?