Having problems copying an image

I'm having problems copying an image. The Image comes from my jar file and I'm trying to copy it to my hard drive. The problem is that it seems to add extra characters at the beggining and maybe at the end as well. I used a Hex Editor to compare the contents.
Anyway I was wondering if anyone could offer suggestions.
My code is listed below in case that helps.
"in" is an InputStream, "content" is a byte array, and "out" is an OutputStream
try {
   in = getClass().getResourceAsStream("LoveGameSm.gif");
   content = new byte[in.available()];
   out = new ObjectOutputStream(new FileOutputStream("Tmp.gif"));
   in.read(content);
   out.write(content);
   out.flush();
   in.close();
   out.close();
catch(Exception e)  {
   e.printStackTrace();
   return null;
}

The problem is in the use of ObjectOutputStream... this does not work the way you think it does. It is used to serialize an object to an output stream. A serialized object is just the on-disk representation of a Java object. So, you are getting a serialized copy of a byte array, which is why there are extra characters.
Instead, just leave off the ObjectOutputStream stuff, and write to the FileOutputStream. Better yet, wrap it in a BufferedOutputStream to increase performance.

Similar Messages

  • I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found

    I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found this?

    You need to give a lot more information about the media specifications and the project properties you're using in the different projects.

  • Since installing LION having problems getting photo images to upload?

    since installing LION having problems getting photo images to upload? anyone else havie this problem? I did finally get a message that the format was wrong, but I have changed nothing on my camera. Only change was the installing of LION.

    This is from the Kodak site which says there is no Lion compatible driver/software yet, but it is coming in late August:
    http://support.en.kodak.com/app/answers/detail/a_id/41646/kw/os%20x%20lion/selec ted/true
    If you don't want to wait there is always this kind of device for less than $10 (I don't own or endorse it):
    http://www.walmart.com/ip/Moultrie-USB-2.0-SD-Card-Reader/14972138

  • I am having problems saving certain images

    I am having problems saving certain images. For example, on Ebay while viewing an auction item, when you click on the image to view the larger picture it opens in a new window. With Internet Explorer, you can "right-click" and "save picture as". With Firefox 3.6.9 the "save picture as" option is not availabale. Other options such as save "save page as" are available, but not "save as," or "save picture as." Any ideas? Thanks

    I have found a solution to the problem. Apparently there is an addon to fix this. Had no idea a specific google search for "trouble saving images on ebay" would turn up anything.
    https://addons.mozilla.org/en-US/firefox/addon/13802/

  • Imovie: i am having problems sizing my image

    imovie: i am having problems sizing my image when i convert the cells into a 'project'.
    I can see all the image in full, - until i drag it into project area, then in the view window the image is too large and is cut in half.
    i have adjusted the PAL size . large full view etc..
    I tired exporting and even when exported to quicktime, the image is cut in half.
    does anybody have any idea what the problem is?
    thanks

    Hello lucglobal68,
    The following article contains information regarding the options you have with cropping (or not cropping, if you'd like the entire image to show) images in iMovie.
    iMovie '11: Crop video clips or still images
    http://support.apple.com/kb/PH2232
    Cheers,
    Allen

  • Having problems copying and pasting

    Just upgraded to 10.9.3 - having trouble copying and pasting. Hard to highlight text.

    Thank you for responding. I am copying content officially from travel destination out hotel websites and pasting descriptive copy into Word 2007 to write a Press release. If in a, Press release there are links I need to research to make sure they are correct, copying and pasting the url from word to firefox doesn't work. I have to copy and paste into wordpad and then copy to word. huge pain. thanks for the help

  • Having problems scaling down image

    Hi there, I was hoping somebody here may be able to answer a query I have.
    I'm currently creating the following icon in Illustrator:
    The Image was created within illustrator using the shape and pathfinder tools, the problem I'm having is that when I come to scaling it down, this happens:
    The strange thing is that when I scale the icon upwards it does it perfectly as it should, but the problems are coming from scaling it down.
    I think it may have something to do with the size of the image already, it's quite small, approximately 50px accross. I'm looking to get it down to about 25-30 px accross, but when i take it down to about 40px the distortion occurs and gets worse as I make it smaller.. I thought it may have something to do with the handles on the anchor points overlapping? But I'm not so sure as I've never had an issue like this before, although I've never worked at this small scale before either.
    Any help on this is much appreciated.
    Thanks in advance,
    Lionel.

    In your transform palette turn OFF align to pixel grid, prior to scaling. Adobe since CS5 has made that to be on by default when you create an RGB document.

  • Having problems copying and pasting in Photoshop CS5

    Hi,
    I'm running Photoshop CS5 on my laptop (Win 7) and desktop (Win 8).
    When I have three documents open and open a New one, I can't get the others to copy and paste by keys or menus...not even by dragging to the new document.
    Same thing happens in both version of Windows. The images are all jpgs, RGB, 8 bit.
    Also, sometimes when I create a New doc, one of the other images suddenly disappear.
    Any ideas what's going on here?
    Thanks in advance for any advice you can offer.
    Biff

    You probably simply crash your graphics acceleration by exhausting all resources. Turn off openGL in the prefs and/or update your graphics driver.
    Mylenium

  • Having problem with importing images to a java applet in web broswer

    I'm creating a mini 2d game just for fun and I am running it as a applet with the JApplet class.
    This is my html file.
    <html>
    <body>
    <applet code=ambiDexApplet.class name=ambiDexApplett archive=ambiDexApplet.jar
         width=640 height=480>
         <param name="Player" value="Player.class">
         <param name="Actor" value="Actor.class">
         <param name="Tail_Bead" value="Tail_Bead.class">
         <param name="Block" value="Block.class">
         <param name="Morphable" value="Morphable.class">
         <param name="Item" value="Item.class">
         <param name="GameObject" value="GameObject.class">
         <param name="leftImg" value="Player_Left3.gif">
         <param name="rightImg" value="Player_Right3.gif">
         <param name="img1" value="bgImgFinal.jpg">
         <param name="img2" value="Block_Tower2.gif">
    </applet>
    </body>
    </html>However every time i try to run the program i get the following error when i open the java console.
    java.security.AccessControlException: access denied (java.io.FilePermission Images\Player_Left3.gif read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    Obviously, the applet is not letting me read the image files. By the way, the .class files and the image files are all in same directory. So can anyone help me please?

    Unfortunately, yes--I've tried it that way over and over, and every other way I could think of.  The files are all in one folder, and I've converted the raw files to both tiffs and jpegs.  I even tried converting them to jpegs at the final pixel dimensions.  Each folder that I have used only contains one type of file, and they are all part of the same sequence and sequentially numbered.  I have even tried renumbering the files with numbers first, numbers last, numbers only, moving underscores.  I moved the files from my external hard-drive to the desktop ... I have a lot less hair than I had only a few days ago!
    I've looked at a few other tutorials that outline the same sequence of steps, and tried them over and over, and then changing one step at a time to make sure that it was not a single step that caused the problem.
    The thing that is really bugging me is that it works fine if I use the different approach of using the place command instead. 
    Anyway, thanks for all of your time.  It's going to be a lot simpler to just stick with 'place' command and I will likely do that, but I tend take things like this as a challenge.  I like to know WHY it won't work for me.  Sometimes it seems that there is just no logical explanation!
    Stuart

  • Having problems copying two sided but not printing two sided of two sided originals

    I have no problem printing items two sided with two sided originals using my computer with Windows 7 but cannot copy using the automatic feeder as that option no longer appears when you click green arrow on the two sided of one sided original.

    Hello,
    The HP Officejet Pro 8600 (N911a) only offer automatic two-sided printing.
    ADF Duplexing (Automatic two sided copying of an original) is only offered by the HP Officejet Pro 8600 Plus (N911g) or Premium (N911n) for that series.
    You may find its specifications below:
    Boost productivity – and save time and paper – with
    automatic two-sided printing and 250-sheet paper tray.
     http://www8.hp.com/h20195/v2/GetPDF.aspx/4AA3-6985EEE.pdf
    To compare with, below is the Officejet Pro 8600 Plus specs which do offer a such:
    Boost productivity with automatic two-sided printing, scanning and copying with 50-page automatic document feeder.
    http://www8.hp.com/h20195/v2/GetPDF.aspx/4AA3-6986EEE.pdf
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Having Problems Copying Files to Burn Disc Folder

    Ok here's the deal. With Tiger I was able to copy files from volume or desktop and paste them in burn disc folder then burn disc from finder. Now whenever I paste them, they paste as alias' (shortcuts) not as the full file. What's going on?
    (Keep in mind I do know the dragging creates shortcuts, I'm not dragging I'm copying and pasting, and it always worked great until I upgraded.)
    This is extremely annoying. I hate burning through programs and I'd really rather not if someone can explain to me how to fix this problem.

    From Mac Help:
    Creating a burn folder
    You can create a burn folder to collect files you want to burn onto a CD or DVD. Burn folders are especially handy for burning several copies of a folder, or for regularly backing up a set of files by burning them to discs.
    To create and use a burn folder:
    Click the desktop (the background area of your screen) if you want to keep the burn folder on the desktop; otherwise, open the window where you want to keep the burn folder.
    Choose File > New Burn Folder, and type a name for the folder.
    Drag to the burn folder the items you want to burn to a disc.
    The Finder places aliases to the items in the burn folder; the originals are not moved.
    When you’re ready to burn the folder’s contents to a disc, double-click the burn folder and click Burn.
    Insert a blank disc into your computer’s optical drive, or into an optical drive connected to your computer, and follow the instructions.
    The original files that the aliases point to are burned to the disc. In addition, if any folder in the burn folder contains aliases, the original files for those aliases are burned to the disc as well.
    If the Finder cannot find the original file for an alias, it asks whether to cancel burning or to continue without that item. If you cancel, the disc remains empty.
    If a burn folder is in the sidebar of a Finder window, you can quickly burn its contents to a disc by clicking the burn icon beside it.
    ~~~~~~~~
    ~~~~~~~~
    There is a gear on the bottom of the burn folder in Finder, that appears when a blank DVD is loaded, which when clicked will tell you how much room has been used on the disk or the remaining space, can't remember which at this stage.
    I burnt 5 DVDs plus CDs via aliases in burn folders to move all my records from my old iBook to my MacBook Pro, both running Leopard. Believe me it does work. ~ not one coaster either.
    This is a user to user forum, thanks and a smile go a long way.
    By the way Tiger used alias to Burn discs too:
    http://support.apple.com/kb/TA23505?viewlocale=en_US
    Message was edited by: Ashka

  • OS X 10.10.2 Server. Having problems with Netboot Image

    Hey there guys, it's the first time i'm having to deal with an OS X server.
    I've made a Mac Mini into a server, and would like to use it as an Imaging Server for our Company's laptops, which are MB pro's.
    I've checked that i've updated the OS on the Mac Mini and the MacBook Pro that i took the image from to the latestth
    soo... I made the image from the laptop, got it on the Server and it's in the Library/Netboot/NetbootSP0 folder.
    The Server app picks it up, and it's set so that you can install the image on other laptops via Ethernet.
    I'm using an apple Ethernet to thunderbolt adapter for the MacBooks
    At first i thought i've messed up something with the NetBoot image, so I had to Create another one.
    First one got Recognised by the laptops when i try to Boot while pressing [Alt+N], but when it booted that way, nothing happened - it just went to the "Select language screen" that you get when turning it on for the first time.
    The second image wouldn't be recognised at all and same thing happens.
    I can give you any additional info if required, just ask me.
    Thanks

    Without any more detail it looks like you've misconfigured something somewhere? Either the workstation you've used to build the image has somehow not 'taken' properly (don't ask me to explain as it can happen sometimes for no discernible reason) or deploy studio and/or your server (amounts to the same thing) have not been configured properly and/or the network in terms of what the clients use for DNS has not been thought through properly?
    It may be none of the above but they are good places to start the debug process.
    What we need is what you're basing your private network around in terms of DNS; e.g.: server's fully qualified domain name, does it resolve on both pointers, can your clients resolve it on both pointers, have you configured deply studio's depository correctly and so-on.
    You don't need to use alt N. Either use the N key or just use the alt key to select the Boot Disk Manager. If you've valid nbis they'll show up there. DeployStudio's netboot set is just a simple, minimal, network-based bootloader. It's typically not very large. Anywhere from 2-5GB. If your nbis are larger then you've not created what you think you've created.
    Hopefully some of the questions I'm asking will start you looking in the right places?

  • Having problems Masking unwanted images

    I am attempting to process video images of fish passing at a hydroelectric dam and extract the fish from turbulence and other debris in the water. The data was collected on digital video tape and sent to the computer using an NI-1409 card for processing using LabVIEW 6.1. Initial filtering of the data filters most unwanted particles out, but leaves some, and then using IVB ShapeMatch.VI with a fish image works pretty well to identify the actual fish images. However, when I output the data to a file particles from after the initial filtering and fish data are both written to file (data such as center X, center Y, # of pixels etc.). I have tried using Shape Mask FIlter.vi to mask images that don't meet the minimum value for the
    image used in the IVB Shape Match.vi but it hasn't helped, I've even set the acceptance value to 1000. Am I using the wrong mask filter or is there a better way to accept only the desired images? I've attached a copy of the LabVIEW program (I haven't tried to organize the from panel yet).
    Thanks,
    Mark
    P.S. You may see this twice. I received an error the first time I sent it and sent it again
    Attachments:
    big_fish_works2.zip ‏83 KB

    Mark,
    Without images to process, it is difficult to see where the information is changing, but from the sounds of it, you are seeing information you thought was lost being saved in your report. If this is the case, you are most likely not saving the image buffer that you think you are, or there is a race condition where it is being saved before its processed. I know this sounds basic, but insert Windraw windows in your program so you can see you image as it is processed. It helps to use the Vision IMAQ Copy (White vi) so you can see the image at each stage, and it does not change its display as you proceed though the program. This will help so you can see exactly what particles are being sent to the file.
    Best Regards,
    Chris D

  • I am having problems with the image quality when image placing in indesign

    Hi
    I am finding that many illustrations are pixilating when I place them in indesign from illustrator or photoshop.  Some times I can rectify the issue by increasing the size or dpi of the image prior to placement, but I'm sure there must be another way.  How can I improve on the quality and definition of placed images in Indesign?

    This forum is actually about the Cloud, not about using individual programs
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll
    http://forums.adobe.com/community/indesign
    http://forums.adobe.com/community/illustrator
    http://forums.adobe.com/community/photoshop

  • Having problems with swap image (roll over effect)

    I am trying to do a roll over state (swap image) for a linked item on my mock up. I've done this for other pages in the same file, but for some reason on another page, when I build the second state, insert the slice, and  create the swap image on the first state, it previews in the browser with just a white screen and the section that I sliced. How come it is showing a white page in lieu of my entire mock up with the roll over effect?

    I am trying to do a roll over state (swap image) for a linked item on my mock up. I've done this for other pages in the same file, but for some reason on another page, when I build the second state, insert the slice, and  create the swap image on the first state, it previews in the browser with just a white screen and the section that I sliced. How come it is showing a white page in lieu of my entire mock up with the roll over effect?

Maybe you are looking for

  • Problem in GR/IR cClearing A/c (VERY URGENT)

    hi  guru's good morning I ma facing a problem in GR/IR Clearing a/c i am not able to clear GR/IR Clearing (Automatic clearing in F.13) some of entries are cleared and some of entries are not getting cleared, can anybody advise me how to get it clear,

  • Elements 10

    i want to clear the slate and strart again.i have a good basic knowledge of the program but my files and organization is all over the place. i now have the internet so i can watch the videos. i would also like to find more information on how to work

  • Sql Developer 3.0 Notes

    Overall, the new SQL Developer looks very good! I am very excited that you have added a spatial viewer! Bravo!!! I've noticed the followign issues: 1. If you use the new "password" functionality (taken from SQL Plus, of course) more than once during

  • SQL SP Suggestion

    I have a SP that runs everynight to Insert and Update the content of a table based on an excel file (Excel 2010 on Windows Server 20008 R2). Below is my SP and the image represents my table's structure and the excel file format. I just need to double

  • How to get Lion to communicate with WD

    Is there a way to get Lion to communicate with WD Mybook world edititon ( manufacturer's firmware update won't help )