How do I write files that aren't text? Like gif, doc, pdf, jpg, etc.

I don't know how, in java, to write files that are not pure text. I've been using the BufferedReader/Writer but it is not working. Can someone give me some sample code of how I can write file data correctly?

First of all, if you aren't writing text then you shouldn't be using a Writer at all, you should be using an OutputStream. Writers deal with characters, OutputStreams deal with bytes. Second, the hard part of outputting those files is that you have to understand that they each have a defined structure you have to follow. For example, you can find a document that describes how a PDF file must be structured on Adobe's site. (Before you go searching for it, I'll just mention that it is over 500 pages long.) You have to write out bytes that satisfy the rules for the file type and arrange the content within those rules.

Similar Messages

  • How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant.  The files show up on the new MacBook but cannot be opened.  Thanks!

    How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant?  The files show up on the new MacBook but cannot be opened.  Thanks!

    Get info then check permissions then add your curent user name (it was probably different on old Mac) and give your username full read/write permissions.

  • How to play video files that are in Drop box on iPod?

    How to play video files that are in Drop box on iPod?

    I am going to have to write a technote about this, because it comes up a lot.
    Flash Player itself is designed to play SWF content as a browser plugin or as an ActiveX control (when it's IE Windows).
    There is a standalone Flash Player, but that's something Adobe  provides directly as a feature of Flash CS4 Professional. It gets installed with Flash. We have made some standalone players available on http://www.adobe.com/support/flashplayer/downloads.html, but not all (and I don't know why.  Looking into it)
    There are numerous 3rd party standalone SWF players out there though.  Some designed to just play video, others that play full SWF. I suggest a google search of 'play SWF standalone' and read the results.
    On the Mac, consumers who want to play SWF content off their desktop can use the Adobe Media Player. You can import a local SWF (and FLV and other video) and play it in AMP.  Get it here:
    http://www.adobe.com/products/mediaplayer/
    That's Mac only, doesn't work on Windows.

  • How To read/write file on remote server in java

    Hi All,
    How To read/write file on remote server in java? I mean using URL - http://www.xyz.com can I right file to that perticular server.
    Thanks in advance

    If your server support a means of uploading files you can.
    A popular means is [http://en.wikipedia.org/wiki/WebDAV]
    However, by default web server don't allow you upload files, its usually something you need to configure or install.
    I suggest you have a look at your web servers documentation.

  • Hi, somebody knows how to edit a file that I created in corel draw 11 and I need to edit like PDF!!!! is so simple and nobody knows howwwwwwwwwwww!!!!

    Hi, somebody knows how to edit a file that I created in corel draw 11 and I need to edit like PDF!!!! is so simple and nobody knows howwwwwwwwwwww!!!!

    See your other thread.

  • How do I combine files that have already been combined

    How do I combine files that have already been combined?

    Hi Oldshep1959
    I didn't get you ...Please Explain your workflow ...

  • HOW DO I FIND FILES THAT HAVE BEEN TRANSFERED FORM MY PC TO MY MAC

    How do i locate files that have been transfered from my PC to my new MacBook Pro

    Depends how they were transferred. If you used Migration Assistant, a new user was created. Look there in your documents folder. If you used Setup Assistant, look in your documents folder.

  • How do I access files that have been recovered (after a Mavericks problem) with the .cca file extension

    How do I access files that have been recovered (after a Mavericks problem) with the .cca file extension

    First, to access documents you must use an app designed for that specific Document type. So Pages will not be able to open PDFs. The Documents app by Readdle can handle PDFs though. In the latter case, you'd open the app, click the menu icon at its top left, and click Open to go to your iCloud Drive. With Pages, if you had files outside the main Pages folder, click + then iCloud and navigate to the file's location.
    Matt

  • How does the backup file that I would like to use for restore now require a password

    How does the backup file that I would like to use for restore now require a password, when I just Backed it up on 10/30/14

    It requires a password to restore from it because at some point, you checked the box in iTunes to use encrypted backups, at which point you were prompted for, and set a password.
    If you now can't remember what that was, then you can not restore from that backup.

  • How do I restore files that were backed up by Adobe?

    How do I restore Files that were backed up by Adobe?

    Where is the back-up e.g. on removable storage such as CD, DVD or external hard drive?
      If the files are on Photoshop.com, then Elements can sync them back down, by following these steps:
    Launch the Elements program.
    Login to your photoshop.com account
    Open Organizer
    On the menu click Edit à Preferences à Backup/Synchronization
    You should see all of your albums and media files on your photoshop.com account.
    Mark those checkboxes that you want to restore to your computer.
    Click OK.
    N.B. Elements can only sync files back down to your hard drive which reside in albums on Photoshop.com

  • HT1660 how can i view files that i buck up from my old device to i tunes

    how  can you view file that i buck up from old divice to itunes

    Reset and Erase before selling
    Settings>General>Reset>Erase all Content and Settings

  • How do I  create a pdf file that is only part of an existing pdf file??

    How do I  create a pdf file that is only part of an existing pdf file??

    Use Adobe Acrobat. ExportPDF does not do this, or claim to do this.

  • How to find the file that delete from time capsule?

    How to find the file that delete from time capsule?

    I mean I saved JPEG file in Time capsule and unfortunately delete the file. Can I get it back
    IF.... .no other backups have occured since you deleted the file, you might be able to retrieve it using an application like Disk Warrior. It's about $100 as I recall, and there are no guarantees that it will work.
    DiskWarrior 4 - The Disk Utility for Mac  Disk Repair, Mac Directory ...
    Any of the free or low priced utilities that you might see or try will not be able to retrieve a deleted file from a Time Capsule.
    If any backups have occured since you deleted the file, the deleted file has almost certainly been overwritten. No way to retrieve it in that case.

  • How to compare two files in java & uncommon text should print in text file.

    Hi,
    Can any one help me to write Core java program for this.
    How to compare two files in java & uncommon text should print in other text file.
    thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • How to compare two files in Java & uncommon text should print in Diff text

    Hi All,
    can any one help me to write a java program..
    How to compare two files in Java & uncommon text should print in Diff text file..
    Thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

Maybe you are looking for