Start reading in middle of FileInputStream

Hi,
I have a file uploader that i want to implement the functionality to be able to resume failed uploads. I am using a FileInputStream and reading from that into a buffer before uploading(see code below)
FileInputStream in =  new FileInputStream(file);
int nread;
byte[] buf = new byte[2048];
while((nread = in.read(buf, 0, buf.length)) >= 0) {
          //upload to server here
          out.write(buf, 0, nread);
}What i want to do is to be able to start reading somewhere in the FileInputStream object, not have to start at the beginning everytime. So for example if the file uploaded 1000 bytes out of a total 2500 bytes I want to be able to start reading from the inputstream at the 1000 byte point.
If anyone knows how to acomplish this I would be very grateful
Thanks

sabre150 wrote:
You need to skip to the point you want to restart from. Read the Javadoc for InputStream.skip(long ) and make sure you cover the condition where the actual number of bytes skipped is not what you asked for.I was mistakenly under the impression that RandomAccessFile would perform better.
After some benchmarking on a 500M file on my Windows XP machine, I found no significant
difference, so OP, go with sabre's suggestion.

Similar Messages

  • I have downloaded several books into ibooks.  Started reading one and closed it when I was done reading for the day.  Now I want to access other books and when I open ibooks it goes directly to that first book.  What can I do? Help please.

    I have downloaded several books into ibooks.  Started reading one and closed it when I was done reading for the day.  Now I want to access other books and when I open ibooks it goes directly to that first book.  It does not give me the shelf to choose what book I want to read - goes directly to the first book. What can I do? Help please.

    There should be a Library button on the top left. If not ap the middle of the screen to get it to appear.

  • Starting in the middle of an animation won't play the audio

    I was creating a frame-by-frame animation in Flash Pro CC that went with an audio file I added to the project, however when I start from the middle, or anywhere besides the start, the audio won't play, but the animation will. I chatted with a customer support guy and he directed me here. Is there any way to fix this?
    I'm running Windows 8 64-bit.

    if that's an html5 project, no.
    otherwise, assign your sound's sync property (in the properties panel) to stream, not event.

  • Hi. My Macbook Pro won't start, in the middle of the screen, there is a folder sign with a question mark blinking. Thanks a lot!

    Hi. My Macbook Pro won't start, in the middle of the screen, there is a folder sign with a question mark blinking. Thanks a lot!

    Here's a link to a Support page on the topic, which may be of help in finding resolution:
    •A flashing question mark or globe appears when you start your Mac
    There are a few known causes of this symptom, so you'd have to try some things to
    see if you can narrow down the cause; this often accomplished by finding success.
    Hopefully the info there helps.
    Good luck & happy computing!

  • All of my songs now last for one minute thrifty seconds. Most start at the beginning and stop at 90 seconds, a few start in the middle - but total play time is always 1:30. What's wrong?

    All of my songs , when played, now last for exactly one minute thirty seconds. Most start from the beginning and cut off at 90 seconds, some start in the middle. What's wrong?

    It appears that iOS 7.1 fixed this.

  • Call list starts in the middle

    I notice on my iPhone 4 that when I want to place a call from a previous call, the list always starts in the middle! I would have to either scroll up or touch the top to get to the most recent call. Did I miss a setting somewhere or is this a minor bug?

    When I first got the phone, it used to show the top of the list. Does anyone know if this is a deliberate change in iOS, or whether it is a bug?
    Mine always displays in the exact middle of the list (I can tell because I can see the scroll bar). I then always have to scroll back up the list manually to view the most recent calls at the top of the page, which seems counter-intuitive, considering the page is called "Recents". You'd expect it to immediately show the most recent.
    I've seen other posts about this issue, so I know it's not an uncommon issue. The only successful solution I have read is to Reset All Settings, but I've looked at what that means. I will lose 2 years of honing my phone to suit the way I use it; the ordering of all the apps, the sounds, notification settings, everything.
    I don't want to do that.
    So unless there is a less globally impactful solution to this, I guess I can live with it. It's only mildly annoying, just not very Appley because it is not intuitive.

  • All my music and podcasts synced through iTunes are scrambled up. The songs and podcasts start in the middle and skip around. It happends on 3 diffrent Windows computers with 2 diffrent iPhone 4's.

    All my music and podcasts synced through iTunes are scrambled up. The songs and podcasts start in the middle and skip around. It happends on 3 diffrent Windows computers with 2 diffrent iPhone 4's.

    Anyone have any ideas or did my wife and myself just get defective phones?
    Like I said all songs and podcasts start  like 30 sec in them jump back to the intro then to the end then the middle. Its quite crazy.

  • On my Mac Pro how can I get voiceover to start reading at a specific point on a document?, on my Mac Pro how can I get voiceover to start reading at a specific point on a document?

    On my Mac Pro how can I get voiceover to start reading at a specific point in a document, and then continue on to the next paragraph and so on?  Thank you.  Ed

    Welcome to the Apple family!!!! 
    How can I cause the VO cursor(box) show-up/start?
    Press Control-Option and F5.   The F5 key is located on the top row of keys 6th key over.  This is a toggling "Keyboard Shortcut" for turning VoiceOver on and off.
    How can I move the VO cursor to various sentences or paragraphs of an article and have it start reading ... and perhaps even continue reading on to the next paragraph(s) ... even to the end of the article?
    How to read a website with VoiceOver
    Step 1:  Go to the Website
    A quick keyboard shortcut is Command-L.  This will jump you up to the address bar.  Start typing where you want to go.  i.e "www.thewebsite.com"
    Step 2:  Working with Webpage
    VoiceOver will automatically start reading the website.  You can pause the speech by hitting the 'Control Button'. 
    If VoiceOver does not being reading the webpage, then you might have to "Interact" with it.  If VoiceOver say "HTML Content" then press Control-Option-Space-Down Arrow to interact with the webpage.
    Use Control-Option-Right Arrow to move throught the website.  This will speak "EVERYTHING" on the page.
    Most website that I've found have their articles labeled as 'Heading'.  You can jump from heading to heading, by pressing Control-Option-Shift-H.
    If you'd like an itemized alphabetical listing of the site, press Control-Option-I 
    Press Control-Option-Space on the link or article you want to view.
    Step 3.  Reading from Top to Bottom
    Once you found and clicked on the the article/link, use the same 'Heading' command, Control-Option-Shift-H to find the title. 
    After finding the title, press Control-Option-A will start reading from the title on. 
    Note:  If there are any other items (ads, pictures, etc) it will read those too. 
    Tip:  You might be able to activate a feature called the 'Reader'.  The Reader isolates the article and elimanates the ads  The keyboard command is Shift-Command-R.  You can also find it in the Menu Bar (Command-Option-M) under the word 'View' then 'Show Reader'. 
    I am using a MACPro with OSX, probably Mavericks 10.9 (where would I look to see if that is the correct information?)
    You can find this information under the 'Apple menu' in the Menu Bar.  To access the Menu Bar, press Control-Option-M. 
    Go to Apple Menu > About This Mac.  This will open up another window.  Use Control-Option-Right Arrow until you hear 'Version'.  If you purchased it brand new from Apple within the last six month, more than likely you have Mavericks. 
    Recommanded Articles. 
    AppleVis- Commonly used Keyboard Commands
    Chapter 2: Learning VoiceOver Basics
    Chapter 6: Browsing the internet
    Apple Accessibility Resource Page
    The  'Commands Help' Voiceover Menu. Control-Option-H-H.  (hit H twice)  is my best friend.  It's a searchable VoiceOver Menu with most of the VoiceOver command.  Example:  You are looking for the 'Read Current Paragraph' keyboard command.   Press Control-Option-H-H and then type Paragraph.  It will then bring up all the commands with the word paragraph.  I believe there are three.   
    As from the Trackpad Commands, I've copied and pasted below from Appendix A: Commands and Gestures
    VoiceOver standard gestures
    If you’re using a Multi-Touch trackpad, you can use VoiceOver gestures. VoiceOver provides a set of standard gestures for navigating and interacting with items on the screen. You can’t modify this set of gestures.
    NOTE:Gestures that don’t mention a specific number of fingers are single-finger gestures.
    General
    Enable the Trackpad Commander and VoiceOver gestures
    VO-Two-finger rotate clockwise
    Disable the Trackpad Commander and VoiceOver gestures
    VO-Two-finger rotate counterclockwise
    Turn the screen curtain on or off
    Three-finger triple-tap
    Mute or unmute VoiceOver
    Three-finger double-tap
    Navigation
    Force the VoiceOver cursor into a horizontal or vertical line when you drag a finger across the trackpad
    Hold down the Shift key and drag a finger horizontally or vertically
    Move the VoiceOver cursor to the next item
    Flick right
    Move the VoiceOver cursor to the previous item
    Flick left
    Move content or the scroll bar (depending on the Trackpad Commander setting)
    Three-finger flick in any direction
    Go to the Dock
    This gesture moves the VoiceOver cursor to the Dock wherever it’s positioned on the screen
    Two-finger double-tap near the bottom of the trackpad
    Go to the menu bar
    Two-finger double-tap near the top of the trackpad
    Open the Application Chooser
    Two-finger double-tap on the left side of the trackpad
    Open the Window Chooser
    Two-finger double-tap on the right side of the trackpad
    Jump to another area of the current application
    Press Control while touching a finger on the trackpad
    Interaction
    Speak the item in the VoiceOver cursor or, if there isn’t an item, play a sound effect to indicate a blank area
    Touch (includes tap or dragging)
    Select an item
    Double-tap anywhere on the trackpad
    You can also split-tap (touch one finger and then tap with a second finger on the trackpad)
    Start interacting with the item in the VoiceOver cursor
    Two-finger flick right
    Stop interacting with the item in the VoiceOver cursor
    Two-finger flick left
    Scroll one page up or down
    Three-finger flick up or down
    Escape (close a menu without making a selection)
    Two-finger scrub back and forth
    Increase or decrease the value of a slider, splitter, stepper, or other control
    Flick up (increase) or flick down (decrease)
    Text
    Read the current page, starting at the top
    Two-finger flick up
    Read from the VoiceOver cursor to the end of the current page
    Two-finger flick down
    Pause or resume speaking
    Two-finger tap
    Describe what’s in the VoiceOver cursor
    Three-finger tap
    Change how VoiceOver reads text (by word, line, sentence, or paragraph)
    Press the Command key while touching a finger on the trackpad
    Rotor
    Change the rotor settings
    Two-finger rotate
    Move to the previous item based on the rotor setting
    Flick up
    Move to the next item based on the rotor setting
    Flick down
    To customize other gestures by assigning VoiceOver commands to them, use the Trackpad Commander.
    Assigning VoiceOver commands to gestures
    If you need a reminder about what a gesture does, press VO-K to start keyboard help, and then use the gesture on the trackpad and listen to the description.
    Learning about keys, keyboard shortcuts, and gestures
    Sorry lots of information.  Enjoy.  You

  • I am suddenly having a problem printing 4x6 photos.  The print as though starting in the middle of an 8x10 sheet.  I've checked and double-checked the print settings.  Anyone else have this problem?

    I am suddenly having a problem printing 4x6 photos.  The print as though starting in the middle of an 8x10 sheet.  I've checked and double-checked the print settings.  Anyone else have this problem?

        jsavage9621,
    It pains me to hear about your experience with the Home Phone Connect.  This device usually works seamlessly and is a great alternative to a landline phone.  It sounds like we've done our fair share of work on your account here.  I'm going to go ahead and send you a Private Message so that we can access your account and review any open tickets for you.  I look forward to speaking with you.
    TrevorC_VZW
    Follow us on Twitter @VZWSupport

  • Utl_file how to start reading from a certain position?

    Hi all,
    i'm currently using utl_file to read a text file and import to db. i have managed to do it. however i would like to avoid reading the first line as it is the header. i would also like to avoid the last line as it is the footer.
    how do i use the function of get line to start reading at a certain position? i am also able to get the length but i do not know how to make it start reading from a certain position.
    the length of the first line will always be 9 and length for the last line would be 51.
    here's my code so far:
    set serveroutput on
    declare
    vSFile   utl_file.file_type;
    vNewLine VARCHAR2(4000);
    file_name VARCHAR2(200) := 'read.txt';
    v_exist     BOOLEAN;
    v_length number;
    blocksize   NUMBER;
    temp_value varchar2 (4000);
    BEGIN
      vSFile := utl_file.fopen('MYDIR', file_name,'r');
      IF utl_file.is_open(vSFile) THEN
        LOOP
          BEGIN
            utl_file.get_line(vSFile, vNewLine);
            IF vNewLine IS NULL THEN
              EXIT;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        UTL_FILE.FGETATTR('MYDIR',file_name,v_exist,v_length,blocksize);
        dbms_output.put_line(v_length);
        COMMIT;
      END IF;
      utl_file.fclose(vSFile);
    END read_demo;

    Hi,
    utl_file has an fseek procedure for moving the file pointer around in a file, either absolute or relative number of bytes.
    It's in the documentation, I'm surprised you didn't see it there when you looked before going to the hassle of asking us a question.
    Andre

  • Horizontal scroll thumb to start in the middle?

    Hi,
    To centre the thumb on a horizontal scoll bar, to get it to start in the middle, I would have thought you set the following:
    - Max = 100
    - Min = 0
    - Value = 50
    But for some reason my scroll bars are starting from the far left. And any changes I make seem to make no difference.
    Anyone else have this trouble?
    I've tried the following as well:
    - Max = 1150 (no. of pixels width of my image that I am scolling)
    - Min = 0
    - Value = 550
    Although the thumb moves to the middle of the track in the artboard, within FC, but when I run the project or export it ... the thumb is at the 0 value (the far left)
    Am I doing something wrong?
    Thanks,
    Nick

    You can extend a ViewHandler where you can check if the user is requesting an allowed page:
    public class MyViewHandler extends ViewHandler {
    private final ViewHandler base;
    public WebTikViewHandler(ViewHandler base) {
    this.base = base;
    public UIViewRoot createView(FacesContext facesContext, String viewId) {
    if (!viewId.contains("/app/index.jspx" && isNewSession() ){
    newViewId = "/app/index.jspx";
    return base.createView(facesContext, newViewId);
    You can implement the isNewSession method with a session variable.
    hth,
    Andrej

  • When I activated VoiceOver, capital s was used to start reading.  I cannot turn it off so as to be able to use capital s in ordinary utilities (Word, textedit..)  Restarting did not help.

    When I activated VoiceOver, capital s was used to start reading.  I cannot turn it off so as to be able to use capital s in ordinary utilities (Word, textedit..)  Restarting did not help.

    Hi, benson -
    If it is a matter of VoiceOver being turned on when you press Shift-S, you can change the keyboard command key combo for that. Open System Preferences, select the Keyboard item. In the new window, click the Keyboard Shortcuts button.
    In the left list, click Universal Acess. In the new list on the right, be sure the last item, "Turn VoiceOver on or off", is checkmarked, then click the command-key setting on the right of that line. A small text box will open - enter the new command-key combo you wish to reset it to.
    Suggestion - the original setting for that is Command-F5 (that's the number 5, not the letter S). Unless you have a particular need to use Command-F5 for something else, I would reset it to that. If you do need to set it to something else, include the Command-key as part of the combo - doing so prevents accidental activation when using routine keyboard strokes.

  • When I use voice over to read an epub in my Ibooks app, which is in Dutch, sometimes he start reading a book with an English Female voice and some books he reads with the Dutch male voice (which is good). All my epubs are Dutch books. Can i fix this probl

    when I use voice over to read an epub in my Ibooks app, which is in Dutch, sometimes he start reading a book with an English Female voice and some books he reads with the Dutch male voice (which is good). All my epubs are Dutch books so the English voice sound terrible trying to pronounce Dutch. Can i fix this problem? Thanks, Tom

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • Can i start reading on my kindle and then continue on my ipad

    can i start reading on my kindle and then continue where i left off on my ipad?

    Yes, I do it as well between my Kindle, iPad and Android phone.  I would note that in order for it to work between the Kindle and another device, you need to turn on the wifi connection on the Kindle, at least temporarily, so it can connect and tell your Kindle account where you are in your book.  I don't typically leave my wifi on when using the Kindle because of the battery drain, so I have to remember to turn it on for a minute before I'm done using it.    
    Same thing if you use the Kindle app on your iPad and then want to pick up again on Kindle - you need the wifi on to sync, then turn it off you prefer.
    One other note - sometimes the devices (if already connected to wifi) will sync automatically.  Other times I find I need to bring up the menu and tell it to sync.

  • MacBook pro screen blury with a splash of colors starting in the middle

    Hi, I am a new Mac user, and I've had my macbook pro for 6 months now. Yesterday, when I started the computer, the graphics were blurry and then there was a splash of colors (rainbow of colors) covering the middle to upper part of the screen. The rest of the screen was blurry and a bit blinking.
    I had been moving around with the laptop the whole but I cannot figure out what happened or what I can do to fix this.
    Please help. Thanks.

    Welcome to Apple Discussions!
    Go to System Preferences>Universal Access and be sure the Zoom is turned off and the Enhance Contrast slider is all the way to the left. Sometimes UA features get turned on accidentally with disconcerting results.
    Also, if you can, run the extended version of the Apple Hardware test. You may get a clue in the form of an error code, which could indicate a hardware problem. You should still be under the one year warranty, which should cover whatever is wrong. If UA has not been turned on accidentally, you might have a graphics chip problem or possibly a display problem which Apple would need to fix.
    Good luck!

Maybe you are looking for