Serialization of file data

Hi
I'm sure the answer to this is simple, but I really can't think of how do it:
I have a class, SavedObject, which, at the moment, contains two variables, model and script. These two variables are Strings, pointing to a relative file.
I serialize this file for later use in a game. The problem is, if the two files aren't there, problems occur. What I want to do is to save the file data from the two files at serialization, this way all data is kept together, and theres no way for it to get lost.
The problem is, how?
I want to get the data from a file at serialization, save this data in the serialized file, which is a SavedObject. I then want to be able to load up the SavedObject and have a method that returns a FileInputStream, or similar that can work like any other one. The problem, is how is this done.
Sorry if it's confusion, if need be I'll try and explain a bit better.
Thanks
Adam

The problem isn't as such what do to, it's how to
accomplish it.
Do I read the data into an array of bytes, and
serialize this, and then some how provide a method
from that?
That's an option...
Another would be that in the writeObject implementation at one point you create a file Object, see how big it is (File had a size() method, didn't it?) and write the file size, then open an InputStream from that file and write everything you can read to the OutputStream you got as a paremeter.
The problem is after the file is loaded back up again,
how do I provide the acess tyo the data via. InputStreams?
If you do the above you can read the file size and knowing the amount of bytes read everything back, maybe writing it to a temporary file or storing the data in an array of bytes, and then provide an InputStream that reads from the created file or byte array.
I'm sure there are other / better ways too though...

Similar Messages

  • List View: How to force update of *actual* file dates when sort by date?

    List View: How do I force and update of actual file dates when sort by date?
    When I go in, I often see the sort order and dates from 12-15 hours ago!
    not good

    Hi, did you ever get that Windows® Sharing thing worked out?
    On this problem, If it's just that you need the Finder to wake up to the fact that it needs to update the window give a try with Refresh Finder - 1.3...
    http://www.versiontracker.com/dyn/moreinfo/macosx/33066

  • What are the different ways to upload file data to SAP? Please help

    Hi Experts,
       I have to transfer huge file data (few lakhs records) to SAP business transaction. What are the different ways to do the same? I have heard of BDC and LSMW. But are there any more options?
    Which option is best suited for huge file data?
    Is LSMW an old technology and SAP will not support it any more?
    Kindly answer my queries at the earliest.
    I will be greatful to you if you can help me.
    Thanks
    Gopal

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • Help - "Cannot copy file: Data error (Cyclic Redundancy Check)"

    Hey there,
    I'm having problems with my Zen Mosaic EZ00. Up until a few weeks ago it has been working fine however, since then, has begun to show the error message? "Cannot copy file: Data error (Cyclic Redundancy Check)" whenever I try to copy files on to it. I have tried the recovery software available and it only updated the firmware. Some files do occasionally (and very occasionally) copy but usually it shows the error message and cancels the copy.
    I would really appreciate if anyone could help me with this?
    Many thanks :smileytongue:

    sorry for the double post!
    ive just realised that my ipod isnt actually charging, its just got the orange light blinking!
    not too sure what is going on now!
    lol

  • How to specify  inclusion and exclusion rules for File data sources

    This is the seed URL for a file data source: file://localhost/c:/myDir/
    I want to exclude indexing and searching of files under: file://localhost/c:/myDir/obsolete/
    What is the exact format for the exclusion URL?
    I have tried both file://localhost/c:/myDir/obsolete/ and /myDir/obsolete/
    but neither of it seems to work; it still indexes everything under /myDir/
    Should I just put: /obsolete/ as the exclusion URL?
    Also after initial crawling, if I change the inclusion and or exclusion rules and then run the crawler again, it should update the indexes accordingly. Is that right?
    The version of UltraSearch I am using is 1.0.3.
    Thanks for any help on this.

    Try "/c:/myDir/obsolete/"
    Changing inclusion/exclusion rule does not affect files already crawled. It onyl
    affects next crawling behavior.
    To do any DML to existing data set, use SQL directly on wk$url table under the instance owner.

  • How to upload all excel files data from one folder into internal table.

    Dear All,
    I have one requirement, It is like I want to upload the frontend file data into my internal table, But here my scenario is;
    If I have one folder ( Called : Temp) in my frontend system, in this folder ( Called : Temp)  I have 100 excel files. In each excel file I have some 1000u2019s of entries. All these data of every file I want to take into my internal table.
    If I have one file I can go for, CALL METHOD cl_gui_frontend_services=>file_open_dialog and then upload method to upload. But I want to take all these excel files from that folder at a time, is there any class or any thing is there..? plz help..
    Thanks...
    Edited by: satishsuri on Jan 11, 2011 9:33 AM

    Hi satishsuri ,
    You will have to use 3 methods together :
    CALL METHOD cl_gui_frontend_services=>directory_browse "Browse the Directory
    CALL METHOD cl_gui_frontend_services=>directory_list_files "Get all the files from the directory
    CALL METHOD cl_gui_frontend_services=>gui_upload "Upload each file in a loop
    Example:
    TYPES: BEGIN OF ty_data,
             line TYPE string,
          END OF ty_data.
    DATA: str_file TYPE string,
          str_dir TYPE string,
          it_file_table TYPE STANDARD TABLE OF file_info,
          wa_file_table TYPE file_info,
          v_count TYPE i,
          it_data TYPE STANDARD TABLE OF ty_data,
          wa_data TYPE ty_data.
    CALL METHOD cl_gui_frontend_services=>directory_browse
      CHANGING
        selected_folder = str_dir.
    CALL METHOD cl_gui_frontend_services=>directory_list_files
      EXPORTING
        directory  = str_dir
      CHANGING
        file_table = it_file_table
        count      = v_count.
    LOOP AT it_file_table INTO wa_file_table.
      CONCATENATE str_dir wa_file_table-filename INTO str_file SEPARATED BY '\'.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename = str_file
          filetype = 'ASC'
        CHANGING
          data_tab = it_data.
      LOOP AT it_data INTO wa_data.
        WRITE : / wa_data-line.
      ENDLOOP.
      ULINE.
    ENDLOOP.
    Regards,
    Jovito

  • Integrating Flat File data to LDAP Directory using sunopsis driver

    Hello
    I need to import data from a csv file into a LDAP Directory.
    In order to acheive this, i used Demo physical and logical File data server (called FILE_GENERIC) and set up a new LDAP data server using tutorial "Oracle Data Integrator Driver for LDAP - User's Manual".
    I can manually see and update data on both file and LDAP datastores.
    The fact is that i cannot manage to import/update data from the file to the LDAP directory through a dedicated interface.
    The issue do, i think, come from the PK/FK used by sunopsis relational model to represent the directory.
    LDAP DN is represented by a set of two table representing in my example the organizational units in one hand and the persons in the other hands, linking them through FK in persons to auto-generated PK in organization units. My person table also have a auto generated PK. All the directory datastore tables have been reversed through ODI.
    In my interface, i always use my cn as update key.
    I first tried not to map the person PK in the interface, letting the driver generating it for me (or mapping a null PK). I then catch in operator a message like: " null : java.sql.SQLException: Try to insert null into a non-nullable column".
    Anyway, the first row is created in the directory and a new PK is given into ODI datastore. Curiously, this is not as i would presume the last PK value + 1.
    There are some kinds of gaps in the ID sequences.
    I even tried checking the "tolerated error" into the IKM step called "Insert new row". I'm using IKM shipped with ODI :"IKM SQL Incremental Update". The sequence is finished in operator but due, i guess, to the catched error, the other rows are not processed. (Anyway i shouldn't have to tolerate errors)
    I tried after to put not used custom PK values into my file, then map the PK column to the LDAP datastore PK column without much success: Only one row is processed. Futhermore, the id of the PK in the datastore is different of the one I put in the file.
    I finally tried to generate PK values through SQL instructions by creating new steps in the IKM modul but that did not worked much.
    I really do not see any other ideas to either have the driver construct new PK at insert/update or to make him ignore the null PK problem and process all the rows.
    If anyone do have an idea about it, please share...
    Greetings,
    Adrien

    Hi,
    I am facing an issue who is probably the same.
    using ODI 10.1.3.5, I can't insert new rows into my openLDAP.
    One of the point I see is that the execution take the LDAP server for staging area and want to create I$ table into it, so the data are already imported into the ldap Server.
    thanks for any help.

  • Photoshop CC on Windows 7 is saving the file "date" as the created date not the modified date

    I have been using a much older version of PS (CS2) and just decided to update to PS CC. I have installed the trial version of PS CC and will begin the CC subscription as soon as the trial expires.
    I have noticed that PS CC saves the (main) date of the files as the "created date" not the "modified date" as it pertains to Windows Explorer and the Windows OS.
    Here is what is happening: I have a file that I created in 2007 that I use for a template. It is sized to specific dimensions, etc. and when I do my save as, it automatically saves into the desired file folder, so that's why I use this as a template. I setup a new photo and then drag and drop it into my template, flatten the image and save as. When doing this with PS CS2, the date for the newly saved file was assigned as the modified date (current date and time). So, when I searched for the file in Windows Explorer or when I went to open the file, the date shown for the file was the modified date. NOW, with PS CC when I perform the exact same process and do a save as, the file date shown in Windows Explorer and/or when I go to open the file is showing as the created date (3/9/2007), the date that I created and saved the template I use. This is aggravating to me because now when I want to open a file and sort by date, the date shown in Windows Explorer is not accurate. As far as I can tell, this only happens in PS CC. When I open an old file with ID CC and do a save as, it applies the current date, not the created date. And, when I was using PS CS2, whenever I did a save as the current date was applied as well.
    In summary, when performing a save as, the created date is being applied as the main date instead of the modified date. The question is: Is there a way to change this so that the modified date can be applied as the main date for the file when performing a save as?

    Below are two files created the exact same way on the exact same computer: the top one was saved in PS CS2 and the bottom one was saved in PS CC. Both were saved using the "Save As" command. You will notice that when the "Save As" command was used in CS2 it updated the "Created:" date, however, in the CC version the "Created:" date was not updated, only the "Modified:" date was updated. Is there a way to update the "Created:" date when performing a "Save As" in PS CC?

  • Bdc upload file data into internal table problem with gui_upload fm

    Hello experts,
    my coding is like this ..
    data : begin of itab occurs 0 .
    field1 like mara-matnr,
    field2......
    etc,
    end of itab.
    data: file1 type string.
    parameter :file like rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    static = 'X'
    mask = space
    field_name = 'FILE'
    CHANGING
    file_name = file.
    START-OF-SELECTION.
    FILE1 = FILE . "HERE I AM PASSING INTO STRING
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = FILE1
    FILETYPE = 'ASC'
    has_field_separator = 'X'
    TABLES
    data_tab = itab. " here the data is not populating from the file , it is giving the error like speified table not found.
    HERE i am getting the message like "specified table name not recgonised" . the data is not populating into the itab from the file.
    file structure is same as the internal table.
    I stored the file as .txt( ie in notepad).
    my file is like this..
    10000 200 323 sunndarrr.......
    i had a problem with this bdc , i am getting like "specified table name not recgonised" in the fm gui_upload while debugging.
    when i am using the ws_upload it is working fine.
    please guide me where i have done the mistake.
    thank you so much for all the replies.

    Hi,
    Have a look on the following code.
    TABLES: kna1.
    DATA: BEGIN OF itab1 OCCURS 0,
          str(255),
          END OF itab1.
    DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                = 'D:\ABAP EVE\ffile1.txt'
        filetype                = 'ASC'
      TABLES
        data_tab                = itab1
      EXCEPTIONS
        conversion_error        = 1
        file_open_error         = 2
        file_read_error         = 3
        invalid_type            = 4
        no_batch                = 5
        unknown_error           = 6
        invalid_table_width     = 7
        gui_refuse_filetransfer = 8
        customer_error          = 9
        no_authority            = 10
        OTHERS                  = 11.
    IF sy-subrc <> 0.
      WRITE:/ 'sorry'.
    ELSE.
      LOOP AT itab1.
        SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.
        APPEND itab2.
      ENDLOOP.
      IF sy-subrc = 0.
        LOOP AT itab2.
          WRITE:/ itab2-kunnr,itab2-name1.
          INSERT INTO kna1 VALUES itab2.
        ENDLOOP.
        IF sy-subrc = 0.
          WRITE:/ 'inserted'.
        ELSE.
          WRITE:/ 'not inserted'.
        ENDIF.
      ELSE.
        WRITE:/ 'fail'.
      ENDIF.
    ENDIF.
    Flat file:
    10001,Sadney
    10003,Yogesh
    20005,Madan
    1.U need to define internal table with one field of max size
    2.upload the flat file data into that internal table
    3.split that internal table data into another internal table(having fields)
    <REMOVED BY MODERATOR>
    thanks,
    Chandu
    Edited by: Alvaro Tejada Galindo on Apr 30, 2008 12:17 PM

  • Return file data

    ok, I want to create a sub-routine in a spearate class that when I call it opens up a file and returns the file data result in a string.
    so:
    string = file.GetFile("filename.txt");
    And that gives me the data contained in a file in one string varaible.
    The annoying thing about it is I could do this in 20 seconds using Perl but for the life of me I can't figure out how to do it in java... being relativly new to the language. Web search have only turned up the same web pages and I'm getting desparte.

    since it's a text file (.txt)..you can use this method
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.File;
    import java.io.IOException;
    public String fileToString(String filename) throws IOException{
        String newline = System.getProperty("line.separator");
        BufferedReader in = null;
        StringBuffer buffer = new StringBuffer();
        try{
            in = BufferedReader(new FileReader(new File(filename)));
            String line = null;
            while ((line = in.readLine()) != null)
                buffer.append(line).append(newline);
            return buffer.toString();
        catch (IOException e){ throw e; }
        finally{
            try{ if (in != null) in.close(); }
            catch(Exception e){ System.out.println("Cannot close inpput file: " + filename); }
    // in your class..you call up this method like this
    String strFile;   // the string that holds the content of the file.
    try{
        strFile = fileToString(filename);
    catch (IOException e){ e.printStackTrace(); }better yet, you can use Jakarta Common IO library.
    They have a FileUtils class that have useful methods for you..such as copy file to another destination
    File file = new File("filename.txt");
    String fileContent = FileUtils.readFileToString(file, "UTF-8");  // you can specify the encoding

  • BPM was Picking two files but it was not processing 2nd file data in target

    Hi all,
    I have designed scenario for picking two files and i want to merge this files into single structure and send it target.when i am try to testing my bpm was picking two files but it is processing only file it went target system.i have steructe for source like
    source1     target
    root        header
    a           item 0 to unbounded
    b            a
    c            b
                 c
    source2     item1 duplicated structure
    a            a
    b            b
    c            c
    i am getting two source files with the same structure but i have to map it one target structure and i want to map both source fileds to one target structre under item node so i was duplicated item node and mapped a b c fields from both(2 source structures).while testing BPM is picking two file bu in the target i am getting only first file data under item node,whatever i mapped with duplicate structure with second file i am not getting into target file(target is standard proxy structure so cant' create new one item node in that occurance is 0 to unbounded thats y i duplicated node while testing interface mapping its working fine).can anyone suggest solution for this problem.
    Thanks,
    Seshagiri.

    Hi,
    In BPM follow the below steps and hopefully your problem will be solved.
    1.     Configure one sender CC to get the files from your application server, once the files hit the BPM now you need to
                         configure your BPM accordingly.
    2.     Use the Receiver step in BPM to receive the messages. Use the correlation step to get the correct files.
    3.     Use container and append the files, so both the files will be append, this means the message content will
                         have 1header, body, footer, 2header, body, footer.
    4.     If you want to split the message to different receiver then use the fork step else leave it.
    5.     Use the transformation step, the transformation step will call the message mapping. Provide the correct message
                         mapping.
    6.     Now use the sender step to send the message to the receiver-target system. In this step use the split value for each
                          concept if you want to generate two different files.
    7.     Configure 1 receiver CC to generate both the files.
    Hope this helps.
    Cheers,
    Jay

  • How to store the flat file data into custom table?

    Hi,
    Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
    Regards,
    Sujan

    Hie
    u can use function
    F4_FILENAME
    to pick the file from front-end or location.
    then use function
    WS_UPLOAD
    to upload into
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'   "Function to pick file
        EXPORTING
          field_name = 'p_file'     "file
        IMPORTING
          file_name  = p_file.     "file
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         filename                       = p_file1
        TABLES
          data_tab                      = it_line
    *then loop at it_line splitting it into the fields of your custom table.
    loop at it_line.
              split itline at ',' into
              itab-name
              itab-surname.
    endloop.
    then u can insert the values into yo table from the itab work area.
    regards
    Isaac Prince

  • Flat file data load - ODS - Look up data in Startroutine

    Hi All,
    There is a requirement that I have two ODS say 1) ABC and XYZ.
    For Both ODS , We load flat file data.
    First we load data to ABC for current fiscal period
    During the data load to XYZ, We lookup part nos data in ABC for current fiscal period , if data there , for those part nos we load XYZ Flat file data.
    My requirement is that , I need to fetch part nos data from ABC for Fiscal period < current fisacl period.  Then I need to extract already loaded data for those part nos from XYZ and Mark the flag field as Non reportable .
    How can we achieve this ?
    Please advice
    Thanks
    Ajay

    Hi ,
    Thanks for your reply.
    I have done so. When I add lines of My Internal table data to DATA_PACKAGE, It gives the syntax error that both structures are not unique. We have several fields in XYZ ods but they are not in Communication structure.
    Thats the problem. Also , if I write the code , will it be executed for each datapackage. I mean , for each datapacket process , my code will fetch whole data from ABC and then from XYZ. Repetion will be there?
    Any other logic can i use ?
    Thanks
    Ajay

  • Cannot find file .dat

    After using perl script, will produce three files
    1. file .ctl
    2. file .log
    3. file .dis
    When using sqlloader to load file , error messages founds
    " file .dat cannot be found ". I see that the data that to loaded to table is on file .dis. I usually edit the file .ctl first and add line
    infile 'directory where file .dis located'

    Sounds like you have the old version of Creator. Please go to this website (you need to join the Sun Developer Network first) and download the new one which will not require you to have any license:
    http://developers.sun.com/prodtech/javatools/jscreator/downloads/index.jsp
    Thanks.

  • File Date needs to be insterted into Table

    We process/insert two CSV files from the file system into the DB that is executed from a CRON job(I think).
    The CRON job calls SQLPLUS and calls the stored procedures to load the files. The SPs are using UTIL_FILE to open and read the file.
    This works well but now I need to get the date the file was created and insert that as well.
    Anyone know how I can get file date?

    Hi,
    Some simple method for fetching the creation date of your file from OS and insert it into oracle DB is :-
    Method 1:
    1. in your cron tab fist write a shell script ( is you know the name of your file ) like this
    ls -l my_file.csv | cut -b52-63 > my_file.date
    this will write the creation date of CSV file in to a text file.
    2. Since you know the name of your file ( just file extention is changed ) You can read this file from you stored procedure thru UTL file package. Read the Date from that file an insert into your Db.
    i.e. your unix shell script will contain a command that i have mentioned in step one, and the call of that procedure.
    Method 2:
    Another way is
    create a shell script ( say a.sh ) like this
    1) echo 'insert into x (x) values (' > a.sql
    echo "'" >> a.sql
    ls -l my_file.csv | cut -b52-63 >> a.sql
    echo "'" >>a.sql
    echo ');' >> a.sql
    echo 'commit;' >>a.sql
    sqlplus -s user/pwd@dbnm @a.sql
    2) $ chmod 777 a.sh
    3) $ sh a.sh
    4) $ more a.sql
    insert into x (x) values (
    Jul 5 2002
    commit;
    --- this means just run step 1 and two, add entry in crontab for step 3.
    this will work.
    ( i have written insert statement , like wise u can write your update statement )
    Hope this will help you
    Regards
    Ripudaman

Maybe you are looking for

  • My Time Capsule does not work with existing WiFi

    Following a question solved on March 24 by LaPastenague, but gone bad again. Apple AirPort Time Capsule I felt the need for a physical backup of my data, as I would not completely trust the different clouds. I use, and have used Dropbox for 4-5 years

  • How can I get Firefox to save what folder I last uploaded from?

    I recently updated to FF 5.0.1 from some antiquated version of FF 3. I have set the download destination so that it always saves to the folder of my choosing, but it does not seem to remember the folder I last uploaded from. For example, say I wanted

  • Dual Display using ADC

    Hi. I have PowerMac G5, 1.8GHZ with CRT display and NVDA, Display-A. The PCI card has two output, DVI-I and ADC. DVI-I is connected to SONY display and functioning fine. I want to add another display using ADC. I bought ADC-DVI connector from the app

  • I just got an ipad, and i can't get it to work. Can someone help me?

    Having a prob getting my ipad2 to start up.

  • Standard Report in SAP

    Hello Experts We would like to have Some standard report to check whether Any standard schema or rule changed by Anyone (Consultants) We want to target specifically for a country and standard schema and rules. Any updates appreciated. Regards SK