Why is ByteBuffer crashing?

hi, i have a program where i want to write to a bunch of bytes, in small groups, to a ByteBuffer
of a specific size. Once that ByteBuffer reaches 50K bytes I want to write that whole thing
to a file as a ZipEntry. I have allocated the ByteBuffer and I can write to it the first time, but
the second time I try to write it says I have an IndexOutofBounds Exception. This does not
make sense to me because the first time I write I have 898 bytes written, the same with the
second time, and 898 + 898 < 50K for sure! I have posted the code below. Can anyone
help me? thanks
//variables:
     ByteBuffer buffer;
         int bytesInBuffer;
               if(buffer == null){
                                //the program goes here first, and executes fine....
                    buffer = ByteBuffer.allocate(50000);
                    buffer.put(claim);
                    bytesInBuffer += sizeOfClaim;
                    return true;
               buffer.put(claim,bytesInBuffer,claim.length);  //it crashes here the 2nd time through, even though the capacity of buffer is 50000!
               bytesInBuffer += sizeOfClaim;
               return true;

hi, i have a program where i want to write to a bunch
of bytes, in small groups, to a ByteBuffer
of a specific size. Once that ByteBuffer reaches 50K
bytes I want to write that whole thing
to a file as a ZipEntry. I have allocated the
ByteBuffer and I can write to it the first time, but
the second time I try to write it says I have an
IndexOutofBounds Exception. This does not
make sense to me because the first time I write I
have 898 bytes written, the same with the
second time, and 898 + 898 < 50K for sure! I have
posted the code below. Can anyone
help me? thanks
//variables:
     ByteBuffer buffer;
int bytesInBuffer;
               if(buffer == null){
//the program goes
//the program goes here first, and
re first, and executes fine....
                    buffer = ByteBuffer.allocate(50000);
                    buffer.put(claim);
                    bytesInBuffer += sizeOfClaim;
                    return true;
buffer.put(claim,bytesInBuffer,claim.length);
h);  //it crashes here the 2nd time through, even
though the capacity of buffer is 50000!
               bytesInBuffer += sizeOfClaim;
               return true;
After the first time through be sure to flip the buffer via
a call to ByteBuffer.flip()
(T)

Similar Messages

  • HT1665 There is a bug in the spellchecking functionality when typing in the web view or while using Blogsy App. Why? Why my IPad crashes so often?

    There is a bug in the spellchecking functionality when typing in the web view or while using Blogsy App. Why? Why my IPad crashes so often?

    I have always found spell check to be "buggy" in every version of all of the iOS's that I have run on my original model iPad and my new iPad - especially when replying and typing posts in these forums. It works perfectly in every other application on my iPad but it has never worked perfectly in any web browser that I have used on my iPad - no matter what I have done to try to correct it. That is what MY experience has been with spell check on my iPads.
    As for the crashes on your iPad try these basic troubleshooting steps.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Quit all apps and restart. Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • Last night I downloaded the latest Word update. Today the first Word document crashed and I lost 45 minutes of work in spite of having saved the document numerous times. Why is Word crashing the day after a safety update? I have Office 2008 for Mac

    Last night I downloaded the latest Word update. Today the first Word document crashed and I lost 45 minutes of work in spite of having saved the document numerous times. Why is Word crashing the day after a safety update? I have Office 2008 for Mac

    One way to test is to Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, Test for problem in Safe Mode...
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive
    Reboot, test again.
    If it only does it in Regular Boot, then it could be some hardware problem like Video card, (Quartz is turned off in Safe Mode), or Airport, or 3rd party add-on, Check System Preferences>Accounts>Login Items window to see if it or something relevant is listed.
    Check the System Preferences>Other Row, for 3rd party Pref Panes.
    Also look in these if they exist, some are invisible...
    /private/var/run/StartupItems
    /Library/StartupItems
    /System/Library/StartupItems
    /System/Library/LaunchDaemons
    /Library/LaunchDaemons
    Open Console in Applications>Utilities, check the system log for the date/time of the last problem  & next startup for clues.

  • Why does illustrator crash every time I try to open an .svg?

    Why does illustrator crash every time I try to open an .svg?

    Dunno. Do you have an example SVG that crashes Illy on your computer?

  • Why did itunes crash corrupt my whole computer?

    i hate itunes so much! i tried to download some tunes and the files were corrupted on apples end, it wouldnt let me download them, it kept giving me errors. then you know what happened, itunes lost my whole library, then you know what happened, all my prefrences for all my applications suddenly disappreared. i have no bookmarks, no email settings, nothing. im sooooo ****** off right now its not even funny.
    why did the crash of itunes screw up my whole computer? and what can i do to bring it back to the way it was before itunes blew it up?
    this is unacceptable. because of this, i will never buy anythig from itunes store again.

    Welcome to the Apple Discussion
    I'm sorry to hear of your problems. However, I wonder if iTunes screwed up your computer? Perhaps there's another, core issue with your Hard Disk? Have you run any Hardware Diagnostics?
    Regards
    TD

  • Why does Illustrator crash when saving to a new location on my new MacPro 13" Retina Pro running Yosemite?

    Why does Illustrator crash when saving to a new location on my new MacPro 13" Retina Pro running Yosemite?

    That won't do. What I mean is you have to navigate to the file and make it active in pastebin and then copy the highlighted line like this
    and paste that into your reply.

  • Why premiere CS% crashes opening project and in encore

    I have 12gb ram- CPU-I-7, NVIDIA 5000 plus graphics card, asus 58P motherboard.
    I have a 2 hour project on my time line. When I open the project, the system crashes and about 5 minutes later works fine. I now want to export the timeline to Encore to make a dvd menu. Encore imports(dynamic Link) the sequence and at the 50% mark, crashes.but does not want to open. I have no idea why systems are crashing. I have not rendered the sequence in premiere pro as I don't know if I need to when going to encore. Comments would be appreciated.
    Leo.

    The symptoms you decribe, white screen, the beachball, the not-responding message and the media pending message all are indicative of a Windows problem. Probably you will encounter the same problem when for instance you have 5 large (2+ MB) .HTML files open in Dreamweaver and those files have been modified enternally and need to be reloaded, especially in split mode.
    It boils down to the fact that when opening your project, PR needs to get all those files from disk, or at least the indexed and conformed files into memory, as well as the .PEK files and while it is waiting for that to happen, it shows the media pending message. Windows itself is usually in a hurry to show the not-responding message, while it is waiting to finish a requested task, even when it is responding, albeit slowly.
    My guess is that you haven't tuned your system yet, see Adobe Forums: Guide for installing and tuning a Vista... which also applies to Win7 and your disk setup may be lacking the necessary speed. After following the tuning steps, you can try to delete the media cache and then reopen your project. It will index and conform your clips again, so be a little bit patient for that process to finish.
    Also have a look here: Adobe Forums: Generic Guideline for Disk Setup

  • Why does IE crash when opening a pdf file ?

    Why does IE crash when opening a pdf file ?

    I think this is done by the browser when it is saving a temporary file and there's already a file with that exact name in the temp folder.

  • Why does Safari crash?

    Why does Safari crash on my internal start-up disk and not on a booted SuperDuper external disk?
    Safari started behaving weird with very high CPU usage, then it refused to start up altogether, it doesn't even reach the safari icon when it crashes.
    Did repair disk permissions. No good.
    Around the same day i also lost the connection with my TimeMachine drive (third time this year). I've had it with timemachine.
    Cheers
    rudy raymakers

    Why does Safari crash on my internal start-up disk and not on a booted SuperDuper external disk?
    Safari started behaving weird with very high CPU usage, then it refused to start up altogether, it doesn't even reach the safari icon when it crashes.
    Did repair disk permissions. No good.
    Around the same day i also lost the connection with my TimeMachine drive (third time this year). I've had it with timemachine.
    Cheers
    rudy raymakers

  • Why is Adobe crashing editing 4k

    Do you know why adobe is crashing while editing 4k
    my comp specs are the latest mac pro build up all the way
    Thanks philip
    forumnotifier

    Hi Phillip,
    That sounds like a good setup. Do you get any warning dialog boxes or a crash log? Or do you just get the spinning beach ball?
    Thanks,
    Kevin

  • Why Adobe Bridge crashes all the time ...

    Why Adobe Bridge crashes all the time and despite sending incident report to Apple, I have no answer any more than I can find explanations on the Adobe site. Ma Bridge version is associated with Photoshop elements 4.0 2006 I just reinstalled without success: always lock it. I expect Adobe help. I also have a version of Phoshop CS 2004.
    Thank you Bernard Bardinet

    Hi Bernard,
    The version of Photoshop and Bridge you are using is way too old.
    What MAC OS version are you uisng?
    Regards,
    Rave

  • TS3274 why does ibooks crash on ipad air using 8.02?

    why does ibooks crash on ipad air using 8.02?

    Hi DizzyTaco2,
    If you are having issues with an Apple application such as iBooks freezing or quitting unexpectedly on your iPad, you may want to try some things to troubleshoot.
    First, quit all running applications and test again -
    iOS: Force an app to close
    Next, I would try restarting the iPhone -
    Turn your iOS device off and on (restart) and reset
    If the issue is still present, you may want to restore the iPhone as a new device -
    iOS: How to back up your data and set up your device as a new device
    Thanks for using Apple Support Communities.
    Best,
    Brett L  

  • Anyone have a solution to why Illustrator CC crashes on Mac Pro running OS 10.6.8?

    Anyone have a solution to why Illustrator CC crashes on Mac Pro running OS 10.6.8?

    We recently (yesterday) upgraded our Adobe apps to CC versions. InDesign, Photoshop and Bridge all run perfectly. Illustrator crashes at startup. Tried launching it from Administrator account and it crashes. I have disabled fonts except the bare minimum, no success. If it would launch, then I might be able to narrow it down to an incompatible print driver, but it has to actually be running first. We use no third party plugins with it, so I doubt that is the issue.

  • Why does Safari crash in the middle of a movie or show from the internet?

    Why does Safari crashes in the middle of a movie or show from the internet?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if Safari crashed, you would enter "Safari" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • Why does safari crash after lion upgrade

    why does safari crash after lion upgrade

    Right or control click the Safari app in the Applications folder then click Get Info.
    In the Get Info panel, look for the Safari version number. If it's prior to Safari 6, updating to Safari 6 may help.
    Click here >  Safari Quits Every Time Opened: Apple Support Communities
    Then click the link posted by:  gregoryfromcork
    That will automatically download this file >  Safari6Lion.pkg.download
    Now quit Safari.
    Go to your Downloads folder and double click that file and follow the instructions for installing.
    Then restart your Mac, try Safari.
    If you already have Safari 6 installed, post a crash report.
    If Safari has just crashed, press the Report button on the CrashReporter dialog box to view the crash  information.
    Copy/paste the entire contents of the Crash Reporter window into your reply including the, "binary images" sesction.
    f the crash report dialog does not appear or the crash is hard to reproduce, crash logs can be retrieved from the ~/Library/Logs/CrashReporter> folder.

Maybe you are looking for

  • ORA-00472: PMON  process terminated with error

    Hi, I got this error in alert log.But the clients didn't complain they had a downtime.But in alert log I see the following.Why the db got restarted and why the clients could not notice it.Can somebody please reply why this has happened. Mon Jul 18 12

  • SAP PM object dependency diagram

    Hi All,          We are working on an SAP PM data migration project. Could anyone help me with the load dependency diagram for SAP PM objects. At least a list of SAP PM objects will be of help. Thanks, Gopi

  • I need to get the system time in Micro second

    Hi, In the java API there is a static method �curentTimeMillis�, but I need to get the system time in Micro second there is a equivalent method? Or there exists any suggested solution? Thanks Dany

  • Forms Help doesn't work

    F1 and ctrl+h cannot invoke Help in Forms 6.0. They worked before. What's wrong? Thanks for help.

  • OM inotype does not exist in PO13

    Hi I have created an OM infotype as 9901(pozisiton infotype) in PPCI.And then I completed required settings in infotype checklist.Everything is OK. However in Transaction  PO13 , my infotype is not in thi list.