Saving an object

I have code that is behaving wierd.
When I save a graph a file is produced without any errors, but when I read the object an empty screen (blank) is produced.
Could help me resolve this or offer any suggestions
OutputStream out = null;
     InputStream in = null;
    OutputStream outBuffer = null;
    InputStream inBuffer = null;
    ObjectOutputStream objectOut = null;
    ObjectInputStream objectIn = null;
public void readObject(){
     try{
          in = new FileInputStream("test.gif");
          inBuffer = new BufferedInputStream(in);
          objectIn = new ObjectInputStream(inBuffer);
          objectIn.readObject();
          }catch(Exception e){e.printStackTrace();}
          finally{
               if(objectIn != null)
               try{ objectIn.close();}catch(IOException e){e.printStackTrace();}
public void writeObject(){
     try{
          out = new FileOutputStream("test.gif");
          outBuffer = new BufferedOutputStream(out);
          objectOut = new ObjectOutputStream(outBuffer);
          objectOut.writeObject(graph);
          }catch(Exception e){e.printStackTrace();}
          finally{
               if(objectOut != null)
               try{ objectOut.close();}catch(IOException e){e.printStackTrace();}
     }this is later called in the actionlistener for my menubar
GraphicEvaluator contains the main part of the program
public void actionPerformed (ActionEvent event)
        // Determine which object was the source of the event.
        Object source = event.getSource ();
else if (source == menuSave)
             writeObject();
         else if (source == menuOpen)
               GraphicEvaluator GE = new GraphicEvaluator();
               GE.readObject ();
               GE.setVisible(true);
        }

deos this solve the problem?
having a look at your readObject() method:
public void readObject(){
     try{
          in = new FileInputStream("test.gif");
          inBuffer = new BufferedInputStream(in);
          objectIn = new ObjectInputStream(inBuffer);
          objectIn.readObject();
          }catch(Exception e){e.printStackTrace();}
          finally{
               if(objectIn != null)
               try{ objectIn.close();}catch(IOException e){e.printStackTrace();}
}you should be doing something like this:
public void readObject(){
     try{
          in = new FileInputStream("test.gif");
          inBuffer = new BufferedInputStream(in);
          objectIn = new ObjectInputStream(inBuffer);
          //change this line
          //objectIn.readObject();
          Object obj = objectIn.readObject();
          }catch(Exception e){e.printStackTrace();}
          finally{
               if(objectIn != null)
               try{ objectIn.close();}catch(IOException e){e.printStackTrace();}
obj will now be the object you have read in. Because the ObjectInputStream's readObject returns an object. You should then cast this object to whatever its meant to be

Similar Messages

  • Error while saving for Objective setting

    Hi,
    While saving the Objective setting templates i am getting the error as "Table HRPAD605 is not part of the Customizing object PDST T "
    <u>Error documentation is as follows</u>
    <b>Diagnosis</b>
    Entries in table HRPAD605 cannot be edited in connection with customizing object PDST      T as table HRPAD605 does not belong to customizing object PDST      T, according to the object definition.
    <b>System Response</b>
    The function terminates.
    <b>Procedure</b>
    Check whether the entered objects and keys are correct.Then check in the Implementation Guide whether the object was created correctly.
    Correct the object definition or the entry for the Transport Organizer interface.
    Thanks

    Hello,
    Most likely the is an inconsistency with the transport objects PDST and PDWS. Please run RHSOBJCH to correct this inconsistency.
    Afterwards you should be able to transport the templates via the catalog or via RHMOVE30. Please make sure that the category ID in the target system is the same otherwise you won't be able to locate the template.
    The report RHSOBJCH corrects the missing HR entries in the OBJS table.
    This step you need to perform only once. For OSA you need to overtake
    *5020 up to *5026, also PAD605,606 and 607 references.
    When you have done this (as said, only need to do it once) you can transport the categories and templates via the phap_catalog_pa transaction (righ-mouse click on the to be transported object).
    Hope this helps,
    Regards and Groetjes,
    Maurice

  • Error while saving the objects in ID

    Dear All,
    When I am saving the objects in ID, I am facing with the following error:
    <b>[SAP_NWMss][SQLServer JDBC Driver][SQLServer]Could not allocate space for object 'XI_DIRDATACHANNEL' in database 'XD1' because the 'PRIMARY' filegroup is full</b>
    Please guide how to solve this error.
    Warm regards,
    n.jain

    Hi Nishu,
    ask your xi basis guys to see the disk space of your xi system.........i think the log files of your xi system have consumed too much space on your xi system.... ask your basis guys to make some space available in your xi system then your this problem will be resolved.......
    Thanks,
    Rajeev Gupta

  • Problem while saving an object under a dev class

    hi all,
            Here is a problem while saving an object under a development class.... I created a Z program (ZSORDER)  through SE38 and while i was saving that Z program under a development class called SALES it shows an error message like  <b>" customer object program ZSORDER can't be assigned to the package SALES"</b>..... can any one can explain what is the problem....

    hi,
    you should have created your package starting with the letters "Y" or "Z".
    you have created it with the letter "s". SALES.
    's' is reserved to be used by SAP.
    so create the package  with the letters 'y' or 'z' like 'ysales' and you wont be getting that problem.
    try it.
    warm regards,
    Hari Kiran

  • Problem in saving the objects(urgent)

    hi experts,
      I have saved my objects in one request number.Now i want to save the same object in some other request number how to do that.Please provide the solution.
    thanks n regards,
    Ashok.

    Hello Ashok
    If your objects are workbench objects then they can be locked only in a single transport request.
    However, if you want to shuffle objects from one request to another (perhaps they belong together but have been separated into different request by accident) then you can merge the two requests into a single request (transaction SE10): use menu <b>Utilities -> Reorganize -> Merge Request</b>
    Regards
       Uwe

  • Saving java objects without serialization

    Hi!
    I want to save a lot of java objects to file, and be able to restore the data structure that these java objects compose.
    The obvious way to do that, is to use some kind of serialization I guess. But, as I see it, the problem with this approach is that as the data structure expands and new classes are added and present classes are changed (even the name of the classes) this approach fails. If the user has an old data structure that he/she wants to restore there will be a problem with e.g. ClassCastException and the like.
    Now I am wondering if someone could give me some hints of how to solve this problem. What approach should I use instead. Is XML the right way to do it? Someone who has any experience with these problems?
    I would really appreciate some help!
    Best regards
    Lars

    Hi, Lars, funny you should mention this issue. I am
    dealing with the exact same problem at work. Every
    time I release a new version of my software, users
    cannot load files they saved with the previous
    version. This is a big problem !
    And, like you, I am toying with the XML solution.
    On the downside, saving these objects in an XML format
    will take more memory, as XML can be (and should be?)
    textually descriptive. Those ASCII tags and such will
    probably treble the file size of their streamlined
    "serialized" predecessors.
    But memory is cheap, eh ?
    On the plus side, your XML parser can be (by it's nature)
    forgiving if new fields have been added or old ones taken
    away. And that is why Serializable is giving be a headache
    to begin with !
    Two other thoughts cross my mind ...
    For exceedingly large files, a SAX parser (vice DOM) will
    only have a bit 'o the structure in memory at a time, instead
    of having the whole kit and kaboodle in memory (my understanding
    of DOM).
    Also, nothing is stopping me from taking a gander at some of
    the Zip packages ... now where did I run across them ? java.io ? ...
    where once I write out the XML file (saving my objects), I could
    compress 'em for the user, too :-) I seem to recall a ZipStream or
    something while scanning some of the (JDK 1.4?) packages.
    I am looking forward to your response, and those of other interested
    readers sharing their thoughts on this topic, too !
    Eric

  • Saving sound objects on server.

    I have a sound object which i want to save directly on the server without converting it into byte array.
    Can this be achieved? or is there any alternative way of saving sound objects on ther server quickly.
    Extracting and compressing the sound object to bytearray is taking time.

    Settings -> Mail, Contacts and Calendar. Select your POP account and scroll down to Advanced. Under the Incoming Settings, select Delete from server: Never.

  • Error while saving for Objective setting using tcode phap_catalog_pa.

    while executing tcode phap_catalog_pa, i get the error "Table HRPAD605 is not part of customizing Object PDST T. 
    However, when I proceeded further to use the catalog, I am not able to make any changes and the error message i get is "Data was not saved Message no. HRHAP00_TEMPLATE003".
    I also executed the solution mentioned in previous threads on the same problem i.e.  run the program "RHSOBJCH" and executed the adjusting entries but to no avail.
    I have SAP_ALL authorization profile assigned to me. 
    Would be really helpful if someone could share their insights on solutions to rectify this problem.
    Regards,
    Kalpana

    Hi Kalpana,
    Check the configuration whether you have done it correctly or not.
    And try to upload one template which is existing on the system. Download it and upload it as a template.
    If the problem is still there then it will be some configuration issues.
    Thanks & Regards,
    Ganesh R K

  • Saving 3d objects and retrieving back

    I'm using XMLEncoders ....
    its working fine for simple datatypes..but when I tried for Java3D objects.....
    its not saving.....
    For eg :-
    I've variable defined in my class Point.java
    private Point3d first;
    public Point()
    public Point(Point3d f)
    first = new Point3d(f);
    //then get and set methods.....
    public Point3d getFirst()
    return first;
    public void setFirst(Point3d m)
    first = new Point3d(m);
    now the main....when I'm trying to write the Point3d object
    using XMLEncoder.....its internal co-ordinates are not saved
    I mean...first.x,first.y.first.y......
    although I've set these values before writing the object...
    XML file generated says :-
    <void property="first">
    <object class = "javax.vecmath.Point3d>
    </void>
    I've also tried to create a class MyPoint3d.java which extends Point3d and defined getX(),Y,Z and setX(),Y,Z there....and my class Point.java extends MyPoint.java but in that case xml file which is coming is :-<void property="first">
    <object class = "MyPoint3d>
    <void property="x">
    <double>10</double>
    </void>
    same for y and z
    </object>
    </void>
    </void>

    Hi
    This is not an answer, but was wondering how succesful your attempts to use XML Encoder and Decoder were.
    I am about to impliment the xmlencoder on a large java3d scengraph, is it possible to use xml with the top branch group and expect it to save from there?
    Any advice would be greatfully recieved.
    Thanks
    PJ

  • Saving multiples objects into a file

    I want to create a single file that has multiples things inside, like pictures (png) and texts. Does someone knows how it will be the structure of the binary file?
    I'm programming a draw software like photoshop, where my layers are BufferedImages. Theses bufferedImages must be saved into a file to re-open later and edit.
    Please I want just ideas....
    thanks

    If the objects that you store in your file are fairly independent of each other, one thing that comes
    to mind is to make your file a zip file of component files. That way you can use standard tools to examine
    it and edit it if you wish.
    Another thing to note is that if your file is largely a series of images, some image file formats,
    like tiff , jpeg and gif allow you to store sequences of images in one file.
    Here's a demo that creates a tiff file holding four images, then reads the file and displays the images.
    Stardard software like Kodak's "Imaging Preview" will allow you to flip through the images in the file.
    By the way, if you don't have readers/writers for format tiff, you can get them here.
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class IOExample {
        public static void main(String[] args) throws IOException {
            String urlPrefix = "http://www3.us.porsche.com/english/usa/carreragt/modelinformation/experience/desktop/bilder/icon";
            String urlSuffix = "_800x600.jpg";
            int SIZE = 4;
            BufferedImage[] images = new BufferedImage[SIZE];
            for(int i=1; i<=SIZE; ++i)
                images[i-1] = ImageIO.read(new URL(urlPrefix + i + urlSuffix));
            File file = new File("test.tiff");
            file.delete();
            int count = writeImages(images, file);
            if (count < SIZE)
                throw new IOException("Only " + count + " images written");
            images = null;
            images = readImages(file);
            if (images.length < SIZE)
                throw new IOException("Only " + images.length + " images read");
            display(images);
        public static void display(BufferedImage[] images) {
            JFrame f = new JFrame("IOExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel p = new JPanel(new GridLayout(0,1));
            for(int j=0; j<images.length; ++j) {
                JLabel label = new JLabel(new ImageIcon(images[j]));
                label.setBorder(BorderFactory.createEtchedBorder());
                p.add(label);
            f.getContentPane().add(new JScrollPane(p));
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        //suffix is "jpeg", "gif", "png", etc... according to your service providers
        public static ImageWriter getWriter(String suffix) throws IOException {
            Iterator writers = ImageIO.getImageWritersBySuffix(suffix);
            if (!writers.hasNext())
                throw new IOException("no writers for suffix " + suffix);
            return (ImageWriter) writers.next();
        public static ImageReader getReader(String suffix) throws IOException {
            Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
            if (!readers.hasNext())
                throw new IOException("no reader for suffix " + suffix);
            return (ImageReader) readers.next();
        public static int writeImages(BufferedImage[] sources, File destination) throws IOException {
            if (sources.length == 0) {
                System.out.println("Sources is empty!");
                return 0;
            } else {
                ImageWriter writer = getWriter(getSuffix(destination));
                ImageOutputStream out = ImageIO.createImageOutputStream(destination);
                writer.setOutput(out);
                writer.prepareWriteSequence(null);
                for(int i=0; i<sources.length; ++i)
                    writer.writeToSequence(new IIOImage(sources, null, null), null);
    writer.endWriteSequence();
    return sources.length;
    public static BufferedImage[] readImages(File source) throws IOException {
    ImageReader reader = getReader(getSuffix(source));
    ImageInputStream in = ImageIO.createImageInputStream(source);
    reader.setInput(in);
    ArrayList images = new ArrayList();
    GraphicsConfiguration gc = getDefaultConfiguration();
    try {
    for(int j=0; true; ++j)
    images.add(toCompatibleImage(reader.read(j), gc));
    } catch(IndexOutOfBoundsException e) {
    return (BufferedImage[]) images.toArray(new BufferedImage[images.size()]);
    public static String getSuffix(File file) throws IOException {
    String filename = file.getName();
    int index = filename.lastIndexOf('.');
    if (index == -1)
    throw new IOException("No suffix given for file " + file);
    return filename.substring(1+index);
    //make compatible with gc for faster rendering
    public static BufferedImage toCompatibleImage(BufferedImage image, GraphicsConfiguration gc) {
    int w = image.getWidth(), h = image.getHeight();
    int transparency = image.getColorModel().getTransparency();
    BufferedImage result = gc.createCompatibleImage(w, h, transparency);
    Graphics2D g = result.createGraphics();
    g.drawRenderedImage(image, null);
    g.dispose();
    return result;
    public static GraphicsConfiguration getDefaultConfiguration() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();

  • Saving activeX object

    Hi to everybody, I am trying to build an installer and in the middle of the process it is stopped showing the next message: "An error ocurred while saving an activeX object".
    Can anybodody tell me why can it be happening?
    I am using LView 7.1.1.
    Thanks in advance
    jm

    Hi again,
    what I want to say is that I think I should know the ".dll" files that I have to convert. But my problem is that I do not know which file I have to select to be converted. What I say is I do not have any information related to this in the error message.
    Thanks for your help
    jm

  • Saving dynamic objects in a container to a dataGrid

    I have an app which contains a dataGrid and a VBox container.
    dataGrid columns = username | objects
    VBox = holds children, objects (SWFLoaders)
    How would I be able to get the children back out of the
    dataGrid / save them to the dataGrid? Right now I'm using a
    VBox.getChildren(); and a dataGrid.selectedItem.objects =
    VBox.getChildren(); to get the information in. Is there any way to
    render it back out to the VBox so each user could have a different
    set of objects?
    Editing to show what the getChildren is returning - >
    AppName1.VBox.childName1,AppName1.VBox.childName2,AppName1.VBox.childName3,
    (etc)
    Any help, much appreciated.

    peterent:
    Let me try to clarify.
    I'm using a VBox to visually display a series of graphics. I
    am getting those graphics into the VBox by adding them as children.
    I'm using a dataGrid to hold data about a user, and it is set
    up to hold multiple users. Each user has a series of data that is
    redisplayed when you select their index in the datagrid. This is
    all textual data, so I figured out how to get it to save into the
    datagrid without too much trouble. Also I figured out how to
    redisplay the selected data once it was out.
    (Every column in the datagrid is set to not be visible except
    for the name)
    The big problem I'm having is turning the children of the
    VBox into something that would a> save easily to the dataGrid
    and b> load easily back into the VBox. This way, in addition to
    the data that I already have for each user, I could also save a
    series of graphics, that I could load back in at a later time into
    the VBox.
    I kinda went down the roads of considering using states
    today. But I don't really know how to dynamically generate a state
    which would then save into a dataGrid, and then have that state
    work for many different end-users.
    So, I hope this cleared things up a little bit. If not, or if
    you think you might know what I'm sniffing at but aren't totally
    sure, I could show you my source / app.

  • Graphical Mapping Error: Unexpected Exception-While saving Mapping Object

    Hello Experts,
    I am unable to save Message Mapping in PI7.11 with following version details:
    Version
    Service Pack:03
    Release:NW711_03_REL
    We already had this issue before but after applying Service Path it got resolved.. but now again its giving the same issue.. can any one came accross such issue?? any solution? we are in the critical development stage and wondering for solution.
    Thanks
    Rajeev

    Hello,
    Try to check locked objects in NetWeaver administrator <pi_host>:<pi_port>/nwa on Intagration Repository Tab. If your MM object locked just unlock them and try to save again.
    BR,
    Dzmitry

  • Saving Data Objects in INDX-Type Database

    Hi,
    I am using the EXPORT statement to store data in a table into INDx table.
    EXPORT gt_update TO DATABASE indx(tt) ID index.
    And then I am using IMPORT statement to get that data.
    IMPORT gt_update to tb_update FROM DATABASE indx(tt) ID 'TTUPDATE'.
    The 'TT' is put into INDX- RELID and 'TTUPDATE' into INDX-SRTFD.
    The Export statement was working fine and a record got created in INDX table, but the IMPORT is not working. Can anyone please let me know what could be the problem ?
    'gt_update' and 'tb_update' are of the same type in the IMPORT statement.
    Also please let me know what exactly is the significance of the field INDX-SRTF2.
    Thanks a lot in Advance.

    My reason for using data clusters is that there is huge amount to data to be retrieved from database, so we have decided to get that data and put it in data clusters for faster access of data in the program.
    INDX tables are ideal to store complex strcutures, inlcuding deep data objects. Don't really know if the access is faster, but definitely it takes less space (as data are compressed).
    But I have a doubt, Ideally we should be having another program with the SELECT statement on the table required which needs to be scheduled periodically as a background job to Update the data cluster right ? Otherwise how would the data cluster hold the latest data ?
    It really depends on where you initial data comes from. I mean how data you want to put/update in data cluster are produced. If this is the report, which generates some result and based on that you want to update data cluster, then what you say is true. You would need to run it either manually (periodically) or simply schedule the job, which does the task.
    But as for the update of data cluster itself, I don't think we should use OPEN SQL statements to achieve that.
    What I think you have to do is, each time do a select to know which cluster to extract, then import the result. Next you need to change gt_update locally and place it back (with export) on right data cluster place. Data with same name under same RELID and cluster key will be completely replaced with new (changed) table.
    This is the only way I think of in terms of data cluster update, but maybe there is some other.
    Regards
    Marcin

  • Saving J3D objects in ASE Format ?

    Hello,
    I would like to save objects (simple, composed) build in a J3D scene to the ASE format.
    Has somedy done this before or know interesting ressources ?
    Thanks.
    Gwen

    If you want speed/efficiency, implement Externalizable rather than Serializable.
    More work from you, but you'll get better results.
    This gives you full control over the stream and serialization process.
    Every time you implement an Externalizable you do it with the intimate knowledge of your class, and the minimum requirements of data required to reconstruct it.
    For example, if some stateful object has been created but not initialized your writeExternal method could just write a single boolean to signify everything is null/not initialized. On the other hand, if there's a lot of data to write, you could use a standard compression system, or invent a specialized one. If you have an int[100000] and only one of the values are non-zero at the time of serialization it makes little sense to write 99999 zeroes into the stream.
    I'd be surprised to see a product using a generic serialization scheme that could consistently serialize an object hierarchy faster than custom code for that hierarchy.
    Having said that, life is much easier and less error prone when a tested trusted product does it for you.

  • Saving file object to current Directory.

    Ok I did a file transfer thing, after I receive the file object, how do I save it to the current directory?
    Thanks.

    This saves an empty file.It's up to you to put data in it. I have no idea where your data is coming from.
    I wanna save the file and the contents to the current
    directory.What contents?
    Any ideas?Look at the OutputStream and Reader interfaces in the API.

Maybe you are looking for

  • More Than One Computer Trying to Access Web = Very Slow Download Speeds?

    We have Verizon DSL with a basic Westell modem, which supposedly is only a modem with no router capabilities. We have an Airport Extreme Snow Base Station that acts as a WDS Main, with one other AEB Snow as a WDS Remote. All computers have unique ip

  • Awg710 convert from 5.1 to

    Would someone be so kind to help convert the attached LV version 5.1 files to version 11? Much appreciated, LAW Solved! Go to Solution. Attachments: AWG.VI ‏160 KB AWG.LLB ‏420 KB

  • XML Element of XML Element of XML Element (and so on...)

    Here is my XML data (shorted, in a file myFile): <LiveData> <Voltage> <Total> <VoltageNow>1052</VoltageNow> </Total> </Voltage> <Power> <Total> <PowerNow>345</PowerNow> </Total> </LiveData> I would like to get the VoltageNow and PowerNow values, but

  • Attempting to create a rollover in Dreamweaver

    Attempting to create a rollover in Dreamweaver but when doing so the only way it works is if you approach it from the bottom and not all around. Please see code below and please advise if this is correct or if there is something i may need to change.

  • Restoring deleted photos from lightroom hard drive

    If my photos were deleted from my lightroom hard drive, what is the best method to re-import or restore my "back up photos" back into my drive and original catalog?