How to save graphics into file?

I've written application "Drawing Pad" - simple draw line, scribble, etc. I need to save into file graphics from the pad. How to do it, please help!!!
I've tried the following:
File outputFile=new File("mylife.txt"); // declare a file output object
FileOutputStream out = new FileOutputStream(outputFile);
     try
          DrawPad fileData = pad;
          out.write(fileData);
          out.close();
     catch (Exception e)
          System.err.println ("Error writing to file");
     }It doesn't work. Do I need to convert data into string? Or what else to do?

...what exactly are you trying to do? If you want to save the image your pad shows, it's pretty easy:
1. Create a BufferedImage with the same size as your pas
2. Call pad.paint(image.getGraphics()); to put the pad's content into the image
3. Use ImageIO.write(...) to store your image in a jpg/png file.
If, on the other hand, you are trying to store your pad object in a byte stream (which is generally not a good idea for long time persistence), you will have to use ObjectOutputStream as mentioned above and have your DrawPad class implement java.io.Serializable. Check out the tutorials on this issue, but i really doubt this is what you are trying to do.

Similar Messages

  • How to save the report file in network drive

    Hi experts,
    Can any one of you pls tell me how can  save the report file in network drive.
    My requirement:
    by running a report i wll get daily data into a list.SO, i want to keep this in a common drive (network drive:Z) where every one can acces the txt file.
    I want the code in SAP to design this.
    Awaiting for an early reply.

    Is the Z drive in the application or presentation server ?
    make sure the server has write access to the required folder
    for presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename              = 'c:\test_xls.xls'
        filetype              = 'ASC'
        write_field_separator = 'X'
      TABLES
        data_tab              = itab.
    for the application server, use
    data: outfile(120).
      OPEN DATASET outfile FOR APPENDING IN TEXT MODE ENCODING DEFAULT.

  • Please can someone tell me how to save a MP3 file from my email on my iPad so I can put in on Facebook? Thankyou

    Please can someone tell me how to save a MP3 file from my email on my iPad so I can put it on Faceboo? I use hotmail and please tell me step by step as I am not a tech guru lol. Thankyou

    Hi jscher200,
    Thank you for your reply, sorry for the VERY late late response, but I have just figured out how to control this separate 'panel'. I find it really useful for monitoring Google Analytics in as it can just sit there running. It does have its limitations, as it's a limited size (you can't expand it to full screen view), so you can only ever see a vertical section of a website and need to scroll to look to the right or left, but I have the live view of people accessing my website running on there and if the numbers start racking up at any time, I can scroll to look and see what pages they are accessing, where they've been referred from, etc.
    To get it to work, you save a website address in the Bookmarks Toolbar and when you can see it sitting on the toolbar at the top of the screen with its little icon, right click on it then click 'properties', then tick the box 'Load this bookmark in the sidebar'. The next time you click on this bookmark to open the website, it will load in this sidebar, which looks like a separate 'window' but is immovable. You can only have one sidebar application running at a time, but can change it by right clicking on the bookmark you want to load in there and it will then change to that one next time you click on that bookmark.
    I hope this might be useful to others, as I asked for help with this on loads of forums and not one person knew that this existed - even really skilled techies!

  • How to save a numbers file to a pdf file of multiple pages instead of one giant long page?

    How to save a numbers file to a pdf file of multiple pages instead of one giant long page?

    Hi DW,
    Numbers 3.2.2
    Instead of Menu > File > Export To,  use Menu > File > Print...
    That takes you to Print Preview.
    In the Print Setup panel, Click on the Print... button lower right (it won't print yet).
    That opens the Print Dialogue.
    Click on the PDF Pop-Up Menu lower left.
    Choose Open PDF in Preview or Save as PDF.
    That will have page breaks and will be full sized.
    Print from Preview.
    Regards,
    Ian.

  • How to save the pdf file or word doc into sap table

    Hi Expertu2019s
       I have a pfd file in my presentation server .Now I want to save the pdf file into sap table using module pool program. Whenever i need, I want to open that file from the table and show it in the Screen. Please any one tell me how I can save the file. What is the table name, guide me.
    Regards,
    S.Nehru.

    Hi,
    Try the following code
    FORM gui_upload.
      DATA: lv_filetype(10) TYPE c,
            lv_gui_sep TYPE c,
            lv_file_name TYPE string.
      lv_filetype = 'PDF'.
      lv_file_name = <name of ur file>.
    DATA: tb_file_data TYPE TABLE OF text4096.
    * FM call to upload file
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = lv_file_name
          filetype                = lv_filetype
          has_field_separator     = lv_gui_sep
        TABLES
          data_tab                = tb_file_data
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "gui_upload
    I dont think you can save the data into sap tables in PDF format.
    With the above code you can save data into an internal table.
    Regards,
    Manish

  • How to save a picture file into Microsoft Access Database?

    I want to save a picture file,such example.jpg file into a Microsoft Access Database in JSP,anybody know how to save picture file into Microsoft Access Database and read this picture file from Microsoft Access Database and then show this picture in a JSP page?
    Thanks in advance.

    Not posible in case of Microsoft Access ..
    You will hv to use oracle for that ....
    search for Blob / Clob

  • How to save an excel file as CSV with semi-colon as data separator?

    We are creating a flat data file to load the flat file data to our BW system with Excel.  When we save the file, there are three kinds of CSV types for selecting from the "Save as type" list box:
    CSV (Comma delimited)
    CSV (Macintosh)
    CSV (MS-DOS)
    There is no CSV (semi colon delimited) type.  If we pick CSV (Comma delimted) as the type, then when clicking the "Preview ..." picture icon under the "DataSource/Trans. Structure" tab of the InfoSource for this flat file (with the CSV radio button checked the Data separator default is ";"), the File Upload Preview window shows the data is messed up that some columns of the excel flat file are combined into one column.
    Since the save type we picked is "CSV (Comma delimited)", then we try to change the default Data separator from ";" to "," in the preview selection screen, but still not helpful!
    How to resolve the above problem?
    Thanks

    Hi Kevin,
    This "," is defined in your windows setting. If you want to have ";" as separator then go to control Panel, select Regional Options, go to Numbers Tab and define the List separator as ";". After that when you will save your excel file as CSV(MS-DOS) it will have ";" as separator. This will make sure that the amounts are not broken in to two different fields while loading.
    Else if you keep "," as separator then you can also go into the Excel and define all number fields as Number without thousand separator.
    Let me know if you have any doubts in this.
    Regards,
    Rohit

  • How to save a video file which uses the setCodecChain method on its video t

    hi! i really need your help please. i got the Code for RotationEffect and i would like to know how to save it to a file instead of playing it simultaneously in a player:
    Here is the code: Plz Help me!!! am doing my final year project
    import java.awt.*;
    import java.awt.event.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    * Sample program to test the RotationEffect.
    public class TestEffect extends Frame implements ControllerListener {
    Processor p;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    public TestEffect() {
         super("Test RotationEffect");
    * Given a media locator, create a processor and use that processor
    * as a player to playback the media.
    * During the processor's Configured state, the RotationEffect is
    * inserted into the video track.
    * Much of the code is just standard code to present media in JMF.
    public boolean open(MediaLocator ml) {
         try {
         p = Manager.createProcessor(ml);
         } catch (Exception e) {
         System.err.println("Failed to create a processor from the given url: " + e);
         return false;
         p.addControllerListener(this);
         // Put the Processor into configured state.
         p.configure();
         if (!waitForState(p.Configured)) {
         System.err.println("Failed to configure the processor.");
         return false;
         // So I can use it as a player.
         p.setContentDescriptor(null);
         // Obtain the track controls.
         TrackControl tc[] = p.getTrackControls();
         if (tc == null) {
         System.err.println("Failed to obtain track controls from the processor.");
         return false;
         // Search for the track control for the video track.
         TrackControl videoTrack = null;
         for (int i = 0; i < tc.length; i++) {
         if (tc.getFormat() instanceof VideoFormat) {
              videoTrack = tc[i];
              break;
         if (videoTrack == null) {
         System.err.println("The input media does not contain a video track.");
         return false;
         System.err.println("Video format: " + videoTrack.getFormat());
         // Instantiate and set the frame access codec to the data flow path.
         try {
         Codec codec[] = { new RotationEffect() };
         videoTrack.setCodecChain(codec);
         } catch (UnsupportedPlugInException e) {
         System.err.println("The processor does not support effects.");
         // Realize the processor.
         p.prefetch();
         if (!waitForState(p.Prefetched)) {
         System.err.println("Failed to realize the processor.");
         return false;
         // Display the visual & control component if there's one.
         setLayout(new BorderLayout());
         Component cc;
         Component vc;
         if ((vc = p.getVisualComponent()) != null) {
         add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null) {
         add("South", cc);
         // Start the processor.
         p.start();
         setVisible(true);
         addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
              p.close();
              System.exit(0);
         return true;
    public void addNotify() {
         super.addNotify();
         pack();
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    boolean waitForState(int state) {
         synchronized (waitSync) {
         try {
              while (p.getState() != state && stateTransitionOK)
              waitSync.wait();
         } catch (Exception e) {}
         return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
         if (evt instanceof ConfigureCompleteEvent ||
         evt instanceof RealizeCompleteEvent ||
         evt instanceof PrefetchCompleteEvent) {
         synchronized (waitSync) {
              stateTransitionOK = true;
              waitSync.notifyAll();
         } else if (evt instanceof ResourceUnavailableEvent) {
         synchronized (waitSync) {
              stateTransitionOK = false;
              waitSync.notifyAll();
         } else if (evt instanceof EndOfMediaEvent) {
         p.close();
         System.exit(0);
    * Main program
    public static void main(String [] args) {
         if (args.length == 0) {
         prUsage();
         System.exit(0);
         String url = args[0];
         if (url.indexOf(":") < 0) {
         prUsage();
         System.exit(0);
         MediaLocator ml;
         if ((ml = new MediaLocator(url)) == null) {
         System.err.println("Cannot build media locator from: " + url);
         System.exit(0);
         TestEffect fa = new TestEffect();
         if (!fa.open(ml))
         System.exit(0);
    static void prUsage() {
         System.err.println("Usage: java TestEffect <url>");

    Can you please send me Your codec class and guide me the way you use it .. i am trying to apply some filters on the movie before presenting. Any help would be appreciated.

  • How to save 150MB BLOB file in the database(SQL server)?

    Dear experts,
    I have written some code to save BLOB into a MS SQLserver7.0 database as follows:
    PreparedStatement ps=connection.prepareStatement("INSERT INTO jdbctest" + "(id, content, image) VALUES (?,?,?)");
    ps.setString(1,"2");
    ps.setString(2,"L11.avi");
    ps.setObject(3,data);
    It works for upto 12MB but for files that are as big as 150MB I always get an SQLException as follows,
    "Exception in thread "main" java.lang.OutOfMemoryError
    <<no stack trace available>>" .
    The SQLserver7.0 database is running on NT server 4. The client machine is SGI UNIX. I'm using i-net JDBC driver.
    It seems I should break the BLOB into chunks before saving into SQLserver but I don't know how to do it.
    Can someone please advise?
    THANKS!
    Yu

    Could you tell me more about it? Thanks.Depends on the application.
    For example for internal use you can set up a shared drive and then everyone gets a mapped read only access to it. Then you use a direct drive reference.
    For external, or just wider internal distribution, you could set up a ftp server. Then the address is just an ftp address.
    I believe there are other variations which can be implemented via browsers and support by the websever. For example loading a word doc via the browser.
    The advantage to the above is that you don't have to push it into the database and it allows for some more flexible storage alternatives. The disadvantages are all the things you might want a database for - like concurrency checking and a single source.

  • How to save objects in file

    Hello, I am concerned with how to save a Vector into a file. Can anyone help me ?

    [url http://java.sun.com/j2se/1.5.0/docs/api/java/io/BufferedWriter.html]java.io.BufferedWriter

  • HOW TO SAVE A TEXT FILE ON AL11

    HOW CAN WE SAVE A TEXT FILE ON THE APPLICATION SERVER AL11 WHICH IS ON THE DESKTOP OR ANY DRIVES.
    CAN SOME ONE GIVE ME THE STEP BY STEP PRCEDURE
    REWARDS IF USEFUL

    Hi,
    Use Tcode CG3Z to upload files to application server and use tocde CG3Y to download file to your desktop.
    Reward points if helpful.
    Regards,
    CS.

  • How to save as .ai file to .eps format ??

    Hi all,
    Could anyone help me out on the below problem.
    I need to write a script which will save a .ai file to .eps file format and store in  to a fixed location. (Ex \\10.99.0.60\epsfile\)..
    This action should happen on executing the script.
            Here we don’t need to enter the file name .It will be saved to the same file name. We just have to change the extension of the file and store it to a fixed location.        Ex: when the current file name is ‘test.ai’ the output file name will be ‘test.eps’
    Please help me on the abhove issue.
    thanks and Regards,
    sanat

    Try this. Cut and paste into the AppleScript Script Editor Application. Save as whatever name in HD>Applications>Adobe Illustrator CS4>Presets>Scripts folder and restart.
    This will open all files of the fileTypes in a folder and resave them as AICS4 files with compression and PDF compatibility. It will do a folder only not a Directory. You'll have to put in your own error handling for bad fonts. It makes all files CMYK and updates legacy text.
    -- BEGIN CODE
    set fileTypes to {"EPSF", "PDF ", "ART5", "TEXT"} -- file types available to resave as Illustrator
    -- get a sourceFolder that holds the files to resave as AI
    set sourceFolder to (choose folder with prompt "Choose a folder with files to resave as Illustrator:") as text
    -- get a list of files of the defined type in the sourceFolder
    tell application "Finder" to set workingFiles to (every file of folder sourceFolder whose file type is in fileTypes) as alias list
    -- now you have your fileList argument
    -- get a destinationFolder to hold the PDFs
    set destinationFolder to choose folder with prompt "Choose a folder to hold the Illustrator files:"
    SaveFilesAsIllustrator14(workingFiles, destinationFolder)
    on SaveFilesAsIllustrator14(fileList, destinationFolder)
        set destinationPath to destinationFolder as string
        repeat with aFile in fileList
            tell application "Finder"
                set fileName to displayed name of aFile -- get displayed name
                set AppleScript's text item delimiters to "."
                set newFileName to text item 1 of fileName
                set newFilePath to destinationPath & newFileName & ".ai"
            end tell
            tell application "Adobe Illustrator"
                open aFile forcing CMYK with options {update legacy text:true}
                save current document in file newFilePath as Illustrator with options {class:Illustrator save options, embed linked files:true, PDF compatible:true, font subset threshold:0.0}
                close current document saving no
            end tell
        end repeat
    end SaveFilesAsIllustrator14
    -- END CODE

  • How to save as AI file with PDF compatability at the same location?

    Hi Guys,
    Requesting for script. Here are the details..
    I  do have lot of AI files (from different paths) which are do not have PDF compatability switch  on. So now I am looking for script that all the files should save as at  the same place (over write) and should switch on the PDF compatability  switch on.
    I tried with Action script, But the problem  is, action scripting is recording the path where I saved first time.  That means, all the files are save as into recorded path. This makes me  some what confusion, because source file will be 1 and save file with PDF  1. So in total 2 files will create which is not good.
    So I am  requesting you that script schould overwirte at the same path and should  switch on the PDF compatability.
    FYI: Using Adobe CS4...
    If you help for this, it is really greatful for me.
    Thanks in advance...
    Regards
    HARI

    #target illustrator
    var df = new Folder('~/Desktop');
    var topLevel = Folder.selectDialog('Please choose your Top Level Folder…', df);
    if (topLevel != null) {
         topLevel = topLevel.fsName
         var fileList = new Array();
         fileListRecursive(topLevel, /\.ai$/i);
         if (fileList.length > 0) {
              main();    
         } else {
              alert('This Folder or sub folders contained NO Illustrator AI files?');    
    function main() {
         with (app) {
              while (documents.length) {
                     activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES);
              //var orginalUIL = userInteractionLevel;    
              //userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
              for (var a = 0; a < fileList.length; a++) {
                   var docRef = open(fileList[a]);
                   with (docRef) {
                        var aiOptions = new IllustratorSaveOptions();
                        aiOptions.compatibility = Compatibility.ILLUSTRATOR12; // Change to 14 for CS4
                        aiOptions.compressed = true;
                        aiOptions.embedICCProfile = true;
                        aiOptions.embedLinkedFiles = false;
                        aiOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
                        aiOptions.fontSubsetThreshold = 0;
                        aiOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;
                        aiOptions.pdfCompatible = true;
                        aiFilePath = new File(fullName);
                        saveAs(aiFilePath, aiOptions);
                        close(SaveOptions.DONOTSAVECHANGES);
              //userInteractionLevel = orginalUIL;
    function fileListRecursive(f, exp) {         
         var t = Folder(f).getFiles();
         for (var i = 0; i < t.length; i++) {
              if (t[i] instanceof File && RegExp(exp).test(t[i].fsName)) fileList.push(t[i]);
              if (t[i] instanceof Folder) fileListRecursive(t[i].fsName, exp);
    }

  • How to save as Excel file type?

    There were no Excel file type under the "Save As" function.  Is there anyway to include Excel file type under this list?  Snapshot attached. 
    Solved!
    Go to Solution.
    Attachments:
    Export_file_types.png ‏28 KB

    Hi NiCoder,
    You have a numer of different options to get data from the DIAdem Data Portal to Excel:
    1)  Save to TDM or TDMS file and use the free TDM Excel Importer to load the data into Excel
    2)  Save to CSV file and use Excel's built-in ASCII file import feature to load the data into Excel
    3)  Load the gfsexcel.dll GPI-DLL and use the "File >> Save as..." option to export an *.xls data file
    4)  Use a custom VBScript to automate any of the above 3 options
    5)  Use a custom VBScript to directly send each Data Portal data channel to a column of values in Excel via ActiveX
    Options 1) and 2) are easiest if you want a purely interactive solution.  Option 1) will export all the data values as well as all the properties.  Option 2) will export all the data values and the name of each channel in the Data Portal, but none of the other properties.  If you choose to use option 3), know ahead of time that this feature is limited to 255 columns and will not export any custom properties, just the properties that existed back in DIAdem 8.1.  Option 4) can add in all the custom properties that are missing in option 2).  Option 5) can export all the data and all custom properties, but it is also the slowest option and involves the most programming.
    Let me know what sounds best to you,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • HOW TO SAVE A SCANNED FILE IN PDF FORMAT

    I HAVE A HP LASER JET M1005MFP PRINTER...
    HOW CAN I SAVE A SCANNED FILE IN PDF FORMAT..???
    PLEASE HELP AS SOON AS POSSIBLE AS IT IS URGENT.

    To get your issue more exposure I would suggest posting it in the commercial forums since the LaserJet M1005 is a commercial product. You can do this at Commercial Forums.
    I hope this helps!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

Maybe you are looking for

  • Report Shows no data

    Hi, i have a problem with oracle reports. I am running oracle Application Server 10G release2 with forms and reports services. On Windows 2000. I have developed an application using oracle forms10g and runs well, then i have some reports done in orac

  • A Cursor List Control for the HomeBoyz

    I wanted a Cursor List Control for use with a Waveform Graph, but I couldn't find one anywhere in the Controls Palette. So during a busy morning of data gathering, I took about an hour to write one by hand. [Since I'm getting to be pretty good at Lab

  • Windows server back up has not backed up the files i asked it to?

    I wanted to back up files on my server, so i had connected an external hard drive and created the back up with Windows SBS Console. After it had said the back up was complete, i looked on the external hard drive to check the files. However, when look

  • Spatial query on view to another schema

    Hi, I am getting the following error on this query : select ufi from cadastre where sdo_filter(geometry, mdsys.sdo_geometry(2003,8311,NULL, sdo_elem_info_array(1,1003,3), sdo_ordinate_array(130.967,-12.510,131.000,-12.486))) = 'TRUE'; ORA-13226: inte

  • FDM configation issue

    Hi experts, when i am going to configuring the FDM, i am getting the error. please help me. when i wm going to configure the web config manager, "Apppool "HyperionFDMAppPool" could not be accesed. cannot create ActiveX component". please help meeeeee