How to append in an encoder created file

I'm using XMLEncoders and XMLDecoders for storage of java objects. Currently I've tried on simple data types only. But the problem is if I want to operate on the XMLEncoder created file from two different programs, then it is giving errors. In one program I'm executing
XMLEncoder e = new XMLEncoder(new BufferedOutputStream
(new FileOutputStream("polledobjects.xml")));
e.writeObject(...);
e.writeObject(...);
e.close();
and in another program I want to append to append a few more objects in the same polledobjects.xml, so I created another XML encoder object and opened the polledobjects.xml in append mode.
XMLEncoder e1 = new XMLEncoder(new BufferedOutputStream(new
FileOutputStream("polledobjects.xml",true)));
e1.writeObject(...);
e1.writeObject(...);
e1.close();
Now, Decoder works fine till the point it goes thru xml portion created by the first program, but as soon as it reached xml portion created by the second program, it gives the error->
java.lang.ArrayIndexOutOfBoundsException: 2
at java.beans.ObjectHandler.dequeueResult(XMLDecoder.java:272)
at java.beans.XMLDecoder.readObject(XMLDecoder.java:150)
at Convert.main(Convert.java:57)
XML file created is :-
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2" class="java.beans.XMLDecoder">
<object class="Data_to_Poll">
<void property="active">
<boolean>true</boolean>
</void>
<void property="agent">
<string>192.9.200.151</string>
</void>
</object>
</java>
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2" class="java.beans.XMLDecoder">
<object class="Data_to_Poll">
<void property="active">
<boolean>true</boolean>
</void>
<void property="agent">
<string>192.9.200.151</string>
</void>
</object>
</java>
I know it is giving problems b'cos it is encountering <?xml tag 2 times in the same xml document, but what should I do if I want to append in the same xml file and in the second program nothing more than filename is known...
plz. help me out....

Well, Instead of writing different objects in the same stream.
e.writeObject(obj1);
e.writeObject(obj2);
First put them in some collection. for eg. a List or Set
Set set = new HashSet();
set.add(obj1);
set.add(obj2);
and then serialize the set e.writeObject(set);
Does this sound like a solution ?

Similar Messages

  • How to append to a signed PDF file

    We have Adobe Acrobat 8.1 Professional on PCs running Vista.
    In the past, we could append a scanned document to a PDF document that has already been signed using a self-created Adobe digital signature.  Now we have docs with a digital signature from a Certificate Authority.  I can no longer append a scanned doc to the signed PDF file.  Is there a way to do this?  Previously, we selected Create PDF > From Scanner > selected Append > and clicked Scan.  The scanned paper file would be added to the existing signed PDF document.  Now, however, we get the message "File can't be appended" when we select Append and navigate to the file signed with a digital signature from a Certificate Authority.  One more factor, the documents we get are now signed with PDF signing software other than Adobe Acrobat.  I tried scanning the doc to a file and then combining and Adobe Acrobat would not allow that either because of the digital signature.  Does anyone know how to do the append procedure now?
    Thanks!

    Click on the "arrow out of box" icon on the menu when you're viewing your PDF document (2nd button from right). then click "E-mail document".

  • How to append data from different import files?

    Dear experts,
    The customer is having different applications running that will output imports files BPC needs at a different time of process. Is it possible to append data which already exist in BPC from import?
    eg. BPC already has a record
    Factory1, Actual, 2008.OCT, Movement1, 30
    import file-
    Factory1, Actual, 2008.OCT, Movement1, 100
    and I need to add them up to become 130.
    Looks like regular import will only replace the original record by the new imported value. I'm still trying...
    Thanks a lot,
    Jim Hsu

    I do not think there is a way to use a standard import package to perform this action.  Typically when you are importing, you are saying this is the new value.  Not increment/decrement the value. 
    I have never had to implement a solution for a problem like this.  However, I would write a custom SSIS package that would extract the BPC data for the same dimensionality being imported and append it with the import file, then import the combined file.  Values sharing the same dimensionality in the same import file are aggregated on the actual import.
    SO your input file has 30, the export gets 100, the combined file has both and the actual value imported would be 130.
    That would be the approach I would take, but others might have more experience in different areas.

  • How to append binary data to existing file in OSB

    Hi,
    I have an OSB project that I need for it to append binary data via ftp.  Here's my current flow:
    MFL binary output --> Replace $body with mfl binary output --> Publish to action (Business service that's configured to ftp binary data).
    However, when the data is ftp'ed the following error is thrown:
    URI = ftp://xxx:21/opt/home/zzz/logs
    Request metadata =
        <xml-fragment>
          <tran:headers xsi:type="ftp:FtpRequestHeaders" xmlns:ftp="http://www.bea.com/wli/sb/transports/ftp" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="h
    ttp://www.w3.org/2001/XMLSchema-instance">
            <ftp:fileName>11802_insert_oh_xfrmr.eai_data</ftp:fileName>
          </tran:headers>
          <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
          <ftp:isFilePath xmlns:ftp="http://www.bea.com/wli/sb/transports/ftp">false</ftp:isFilePath>
        </xml-fragment>
    Payload =
    19266787^CLLL^C711791^CLLL^C^C1178213^CSingle Phase(1)^C63185066204^CA^CConstructed^C358880 NW 4 DR LK MONTAZA^C120/240^C09361^CN/A^CProposed Remove^CAerial^C45718100^C
    Unknown^C^CNo^CNormal Closed^CClamp^CA^C1^C2-Cover^C19266796^CNo^CNo^C15^C^CYes^CYes^CYes^C13200Y/7620 X 22860Y/13200^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
    ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C19266641^Coh_fuse_switch^C63086930001^C4^CN31^CDD0613^C22.9^C63376474601^C8129580^CFalse^C4^COke
    echobee^C43^C0^Cdefault^CYes^C
    >
    ####<Nov 6, 2013 2:28:23 PM EST> <Error> <WliSbTransports> <goxsd1604> <osb_server1> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<
    anonymous>> <BEA1-4B688443B66FA09FFE75> <d2b4601b2fffd9b7:6b9f2297:1422a857ee8:-8000-000000000000171b> <1383766103889> <BEA-381105> <Error occured for the service endpo
    int: com.bea.wli.sb.transports.TransportException: Unable to open data connection. Message is Received error response (553) from FTP server [mpsd1] IP [10.111.19.32] po
    rt [21] status [connected] upon executing command [stor opt/home/zzz/logs/11802_insert_oh_xfrmr.eai_data.a]
    com.bea.wli.sb.transports.TransportException: Unable to open data connection. Message is Received error response (553) from FTP server [mpsd1] IP [10.111.19.32] port [2
    1] status [connected] upon executing command [stor opt/home/icanadm/logs/11802_insert_oh_xfrmr.eai_data.a]
            at com.bea.wli.sb.transports.ftp.connector.FTPTransportProvider.sendMessage(FTPTransportProvider.java:422)
    From what I understand the error code 553 represents a bad file name.  The file name that I'm supplying is 11802_insert_oh_xfrmr.eai_data but it appears that the name is changed to 11802_insert_oh_xfrmr.eai_data.a .  So I did the obvious and changed the file several different ways (without the .eai_data extension, removed the numbers from the file name) but still no luck. 
    Any suggestions?
    Thanks,
    Yusuf

    Thanks Eric.
    I'm using the JCA FTP adapter instead and noticed it's appending the test generated data supplied by the OSB test console.
    However, how can I ensure that the MFL output that I need to append will be placed on a new line? 
    Also, how should I map/assign the MFL binary output to the opaqueElement type base64Binary defined in the WSDL file below?
    Once again here's a sample payload that I need to ensure will be presented on a new line:
    19266787^CLLL^C711791^CLLL^C^C1178213^CSingle Phase(1)^C63185066204^CA^CConstructed^C358880 NW 4 DR LK MONTAZA^C120/240^C09361^CN/A^CProposed Remove^CAerial^C45718100^C
    Unknown^C^CNo^CNormal Closed^CClamp^CA^C1^C2-Cover^C19266796^CNo^CNo^C15^C^CYes^CYes^CYes^C13200Y/7620 X 22860Y/13200^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
    ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C19266641^Coh_fuse_switch^C63086930001^C4^CN31^CDD0613^C22.9^C63376474601^C8129580^CFalse^C4^COke
    echobee^C43^C0^Cdefault^CYes
    Here's the WSDL file that gets generated for the FTP adapter:
    <wsdl:definitions
         name="PutGenericDevice"
         targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/AMS/Project1/PutGenericDevice"
         xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/ftp/AMS/Project1/PutGenericDevice"
         xmlns:opaque="http://xmlns.oracle.com/pcbpel/adapter/opaque/"
         xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
        >
      <plt:partnerLinkType name="Put_plt" >
        <plt:role name="Put_role" >
          <plt:portType name="tns:Put_ptt" />
        </plt:role>
      </plt:partnerLinkType>
        <wsdl:types>
        <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/opaque/"
                xmlns="http://www.w3.org/2001/XMLSchema" >
          <element name="opaqueElement" type="base64Binary"/>
        </schema>
        </wsdl:types>
        <wsdl:message name="Put_msg">
            <wsdl:part name="opaque" element="opaque:opaqueElement"/>
        </wsdl:message>
        <wsdl:portType name="Put_ptt">
            <wsdl:operation name="Put">
                <wsdl:input message="tns:Put_msg"/>
            </wsdl:operation>
        </wsdl:portType>
    </wsdl:definitions>
    Here's the JCA details:
    <adapter-config name="PutGenericDevice" adapter="FTP Adapter" wsdlLocation="PutGenericDevice.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
      <connection-factory location="eis/ftp/DssPut"/>
      <endpoint-interaction portType="Put_ptt" operation="Put">
        <interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPInteractionSpec">
          <property name="PhysicalDirectory" value="/opt/eai/ofmw/Oracle/Middleware_R7/logs"/>
          <property name="FileType" value="binary"/>
          <property name="Append" value="true"/>
          <property name="FileNamingConvention" value="dummy.txt"/>
        </interaction-spec>
      </endpoint-interaction>
    </adapter-config>
    Thanks,
    Yusuf

  • How to append time stamp to TDMS file

    hello all, i would like to append time stamp to a tdms file as the 1st column of the file... the pattern should look like this.. can anyone suggest how to create such a file?
    Time
    Data
    0.001
    2.5545
    0.002
    2.653
    0.003
    1.215
    0.004
    2.6586
    Now on LabVIEW 10.0 on Win7

    I got the below oepratin to do.. i used a Write to Measurement File.vi and selected tdms format and it worked out... however, when i read the same file using read measurement file.vi and selected tdms option in ti, i am observing that on the x-axis graph, i get real-time stamp instead of decimals... i want x-axis as decimals instead of timestamp, and when i selected decimals in waveform graph properties --> display format--> x-axis, i could not select decimal instead of time-stamp... can anyone please let me know how to get what i intend to do?
    Now on LabVIEW 10.0 on Win7
    Attachments:
    Untitled 2.vi ‏68 KB

  • How to append the data in a file

    Dear All,
    i want to continously update one text file that is
    in myfile.txt using java,
    for example username:test:password:test
    like wise how can i append this text with username and password to added in the next next line

    Take a look at this:
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    public class FileWrite {
         public static void main(String[] args) throws IOException {
              BufferedWriter br = new BufferedWriter(new FileWriter("C:\\temp.txt",true));
              br.write("Hello");
              br.newLine();
              br.close();
    }

  • How do I setup users to create files in /Users/Shared with group permissions default to rw and not just r?

    I have setup my iMac with 4 user accounts (for the wife and kids).   Some files I would like them to all have access to and that access be read / write.
    I believe I should use the /Users/Shared directory but when a user creates a file there the permissions are rw for the owner but only r for the group & other.   I would like the permissions to default to rw also for group when the file is created so any of them can edit the shared file.
    Basically the umask is defaulting as 0022 and I would like it to be 0002.
    How can I set their account behavior to be this way by default?  Thanks

    You should be able to take the permissions you have set and "apply to enclosed items." I am trying to attach a picture of what this looks like so my apologies if it does not work.
    Highlight your folder you want and go to File>Get Info or command+I and at the bottom where it has Sharing and Permissions, click the lock button to authenticate. Click the gear and click "apply to enclosed items". See if that works.

  • How to append datas to a text file?

    Hi,
    I want to append the data to a already created text file.When i used Write to text file.vi. It overwrites the previous data.
    Solved!
    Go to Solution.

    Try using the 'set file position' function (file io palette, advanced functions)  before you write the data.
    i.e. open the file, set position to end, write the data, close the file.
    Ian

  • How to append a string from a file to a string???????????

    hi there
    the following code reads a line from a file,
    while (true)
    try
    line = br.readLine();
    catch (IOException e)
    System.out.println("Error reading data file");
    System.exit(1);
    if (line == null) break;
    st = new StringTokenizer(line, delimiterString);
    n = st.countTokens();
    if (first == 0) first = n;
    if (n != first)
    System.out.println("Data format error!");
    System.exit(1);
    how will i append the line to itself each time the loop runs? the line should contain all the lines in the file, not just a single line. thank you

    You can make a StringBuffer object with the same scope as the line String and keep appending to the StringBuffer. You can use StringBuffer's toString() method to get a String back when you need it. You can also do this with a String instead of a StringBuffer using +=, but the String buffer is a lot more efficient.
    StringBuffer wholeFile = new StringBuffer();
    while (true)
    try
    line = br.readLine();
    wholeFile.append(line);  // or put this wherever it makes most sense
    catch (IOException e)
    System.out.println("Error reading data file");
    System.exit(1);
    if (line == null) break;
    st = new StringTokenizer(line, delimiterString);
    n = st.countTokens();
    if (first == 0) first = n;
    if (n != first)
    System.out.println("Data format error!");
    System.exit(1);
    }

  • How to append contents to an existing file contents at the end of file?

    Hi all
    I am Kiran, working with LV8.0  FDS
    I find difficulty while trying to add new file contents(some messages)  to an existing file at the end /begining of a file.
    Whenever i try to do that,it is replacing the previous contents,but i dont need that. i want the contents to be appended.
    Plz suggest me.
    thanks & regards
           kiran

    Hi Kiran,
    yes, I can attach a screenshot
    (open file, set file position to end, write text, close file)
    Message Edited by GerdW on 08-16-2007 03:19 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    append.png ‏2 KB

  • How to read UTF-8 encoded text file randomly?

    I am trying to read a text file which has been encoded in UTF-8. The problem is that I need to access the file randomly. The RandomAccessFile is a low-level class and there seems to be no-way to wrap it in InputStreamReader so that UTF-8 encoding can be done on-the-fly. Is there any easy way to do that. Below is the simplified version of my program.
    import java.io.*;
    public class Test{
            public Test(String filename){
                    try{
                            RandomAccessFile rafTemIn = new RandomAccessFile(new File(filename), "r");
                            while(true){
                                    char chr = rafTemIn.readChar();
                                    System.err.println(chr);
                    } catch (EOFException e) {
                            System.err.println("File read.");
                    } catch (IOException e) {
                            System.err.println("File input error");
            public static void main(String[] args){
                    Test t= new Test("template.idx");
    }

    The file that I am going to read could be few hundreds of MBs or GBs. Hence, I will index interesting items in the file. The index file contain the keyword and the byte offset in the file. So, I will need to seek to any byte to read it. The file could be UTF-8 encoded XML or UTF-8 encoded plain text.
    Also, would like to add-up that in the sample program above I am reading the file sequentially. The concerned class has another method which actually does the reading randomly. If this helps, I am pasting the simplified version of code again but this also includes the said method.
    import java.io.*;
    public class Test{
            long bloc;
            long eloc;
            RandomAccessFile rafTemIn;
            public Test(String filename){
                    bloc=0L;
                    eloc=0L;
                    try{
                            rafTemIn = new RandomAccessFile(new File(filename), "r");
                            while(true){
                                    char chr = rafTemIn.readChar();
                                    System.err.println(chr);
                    } catch (EOFException e) {
                            System.err.println("File read.");
                    } catch (IOException e) {
                            System.err.println("File input error");
            public String getVal(String templateName){
                    String stemval=null;
                    try {
                            rafTemIn.seek(bloc); //bloc is a long value for beginng location to read from. It changes.
                            byte[] b = new byte[(int)(eloc - bloc + 1L)];
                            rafTemIn.read(b,0,(int) (eloc - bloc + 1L));
                            stemval = new String(b,"UTF-8");
                    } catch(IOException eio) {
                            System.err.println("Template Dump file IO error.");
                    return stemval;
            public static void main(String[] args){
                    Test t= new Test("template.idx");
                    System.out.println(t.getVal("wikipedia"));
    }

  • How to Append Date to Export Dump file name

    hi everyone,
    This is 10g on Windows.
    I want my dump file name to reflect the date it was ran on. I'm using the Job Scheduler tool in Database Control.
    So when I try EXPSSU%date.DMP as the dump file name, I get error "dump file name "EXPSSU%d.DMP" contains an invalid substitution variable ."
    what is the correct syntax? I dont care about the formatting of the date - whatever the default is will be OK.
    Thanks, John

    i have the same problem, any one have the solution?!?!??!

  • Create File Permissions

    So I was able to force globally all newly generated / created directories or folders to be set with 700 permissions by editing /etc/profile and changing the UMASK to '077'. That worked great for my Arch Linux workstation but I am now trying to understand how I can force all newly created files I create to have the same permissions. Is there a separate area I would need to set this up globally? I use 'wget' and 'touch' a lot and would like the files generated  by those commands and or 'vim' to have 700 permissions. Does anyone know how I can accomplish this on my system?

    umask 077 results in permissions of -rw------- for files and drwx------ for directories.
    was that not what you wanted?
    (nb: for obvious security reasons, umask won't make files executable by default)

  • How can I create files in unicode format without "byte order mark"?

    Hello together,
    I have to export files in UTF-8 format and have to send them to another partner system which works with linux as operating system.
    I have tried the different possibities to create files with ABAP. But nothing works 100% how I want.
    Some examples:
    1.)
    OPEN DATASET [filename] FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
    If I create a file in this way and download it from application server to local system the result for file format in a unicode text edior like NotePad is "ANSI AS UTF-8". This means I have no BYTE ORDER MARK inside.
    But it is also possible that the file format is only ANSI if the file contains no "special characters", isn't it?
    In my test cases I create 3 files. 2 of them has format "ANSI AS UTF-8", and one only "ANSII".
    After transfer to Linux I get as result 2 times UTF8 and one time ASCII as file format.
    2.)
    OPEN DATASET [filename] FOR OUTPUT IN TEXT MODE ENCODING UTF-8 WITH BYTE ORDER MARK.
    With this syntax the result in local editor looks like ok. I get as format really "UTF-8".
    But I get problems with the system which receives the files.
    All files has the file format UTF-8 on Linux but the interface / script can not read the file with BYTE ORDER MARK.
    This is a very big problem for me.
    Do anybody of you know if it possible to force creation in UTF-8 without a BYTE ORDER MARK?
    This means more or less the first example but all files should have UTF-8 format!
    Thanks in advance
    Christian

    This means it is not possible to create a pure unicode file without the byte order mark?
    You wouldn't happen to know how a file with byte order mark should read on a Linux system?
    Or if this possible or not?
    Regards
    Christian

  • How to create file on application server?

    how to create file on application server?

    Hi,
    The following program illustrates the creation of ifle in app server and reading the file from appli server:
    DATA: ITAB LIKE vbakOCCURS 0 WITH HEADER LINE.
    PARAMETERS: P_VBELN LIKE VBAP-VBELN.
    START-OF-SELECTION.
      SELECT *
        FROM VBAP
        INTO TABLE ITAB
    WHERE VBELN = P_VBELN
        PERFORM WRITE_DATA.
        PERFORM READ_DATA.
    *&      Form  WRITE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_DATA.
    OPEN DATASET 'VBAP_DATA' FOR OUTPUT IN TEXT MODE.
    LOOP AT ITAB.
    TRANSFER ITAB TO 'VBAP_DATA'.
    ENDLOOP.
    CLOSE DATASET 'VBAP_DATA'.
    CLEAR: ITAB, ITAB[].
    ENDFORM.                    " WRITE_DATA
    *&      Form  READ_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM READ_DATA.
    OPEN DATASET 'VBAP_DATA' FOR INPUT IN TEXT MODE.
    DO.
    READ DATASET 'VBAP_DATA' INTO ITAB.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    APPEND ITAB.
    ENDDO.
    CLOSE DATASET 'VBAP_DATA'.
    LOOP AT ITAB.
    WRITE:/ ITAB-VBELN,
            ITAB-POSNR.
    ENDLOOP.
    ENDFORM.                    " READ_DATA
    If it is helpful rewards points
    Regards
    Pratap.M

Maybe you are looking for

  • Spot Healing Brush

    It seems that I must have clicked on something because my Spot Healing Brush does not work like it did before!  When I click on it, I have to click on an area first and cannot change the size of the brush!  At the top it says BRUSH - MODE - SOURCE: S

  • Procedure to update the table records

    I have to write a procedure to update the existing records. I have one staging table and one decode table. staging table is obtained from a interface with cross join of two tables X1 and X2 and lookup with DECODE table. DECODE ITEM_ID ITEM_CODE STORE

  • EDI Idoc -- Receiver JMS Adapter.

    Hi, I'm facing this issue from few days. Sender is EDI Idoc and contains header and Footer. This is placed in the application server of SAP system. From there xi picks the EDI Idoc and sends to JMS server. Facing problem on the receiver JMS Adapter.

  • IMac A 1200 freezes on startup

    iMac A 1200 freezes on startup and screen gets multiple lines on it. Cannot start up even from Snow Leopard DVD or external backup drive.

  • Downgrade ios7 to ios6

    How to downgrade ipad2 from ios7 to ios6. safari, chrome and other browsers are crashing every 2 minutes on ios7. Is anyone facing the same problem?