Write a simple string to a file.

I have a string that is formatted with new lines that I want to write to a file as is. I have not been able to create a File Partner Link that can successfully write the content.
The opaque approach creates an empty file.
I have tried defining a new schema as a string, a delimited and a fixed length and the closest I have come is getting the last line written with fixed length.
This is the input schema. I want to write the file element. The complex_child element contains values I would use to build the file name.
<xs:complexType name="complex_parent_type">
<xs:sequence>
<xs:element name="complex_child" type="ns1:complex_child_type"/>
<xs:element name="file" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Anybody have any success? I would think this should be a simple process. We would prefer not to use embedded Java.
Thanks,
Wes.

Hi Wes,
You could try using this schema:
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="..."
xmlns:tns="..."
elementFormDefault="qualified" attributeFormDefault="unqualified"
nxsd:encoding="US-ASCII" nxsd:stream="chars"
nxsd:version="NXSD" >
<xsd:element name="file" type="xsd:string" nxsd:style="terminated"
                              nxsd:terminatedBy="${eof}">
</xsd:element>
</xsd:schema>
You could copy over the contents of the string that you want to write out into the element above and then use the "invoke" on a file adapter PL to write it out.
Regards,
Narayanan

Similar Messages

  • How to write a plain string into a file using File Adapter

    Hi All,
    I am new to ESB technology. I have created one ESB application to invoke a java web service(Which will return string as result) and to write retrieved result in to a file. To achieve it i have created the file adapter using user defined schema. It was working fine. But, I got the modifications in my requirement to store the returned result(String value) in to a text file without any user defined schema. So i used native format for FileAdapter and mapped the returnedResponse(String value) to opaque:opaqueElement. But i am facing relationship error.
    anybody can help me to solve this issue?.. is there any method to convert a string value to opaqueElement..
    Thanks in advance..

    Hi All,
    I am new to ESB technology. I have created one ESB application to invoke a java web service(Which will return string as result) and to write retrieved result in to a file. To achieve it i have created the file adapter using user defined schema. It was working fine. But, I got the modifications in my requirement to store the returned result(String value) in to a text file without any user defined schema. So i used native format for FileAdapter and mapped the returnedResponse(String value) to opaque:opaqueElement. But i am facing relationship error.
    anybody can help me to solve this issue?.. is there any method to convert a string value to opaqueElement..
    Thanks in advance..

  • 3D string array to file

    How can I write a 3D string array to file?

    sascha:
    You could do this a lot of different ways.
    The first and most obvious thing that comes to my mind is that you can
    think about a 3D array as an array of 2D arrays. (For that matter a
    2D array is an array of 1D arrays.)
    Thus you could use a for loop to index your 3D array down to 2D and
    then perform multiple writes to write each 2D array "element" of this
    array of 2D arrays to disk. You would probably want to write some
    sort of header which defines how many dimensions there are in the
    array so that whatever reads it back later will have an easier time
    reading it back. (Otherwise you'd have to implement EOF handling for
    the read back portion.)
    To read it back you just use the same logic but build a 3D array using
    a 2D read inside a for loop.
    Dou
    glas De Clue
    LabVIEW developer (looking for a job...
    [email protected]
    [email protected] (SaschaS) wrote in message news:...
    > How can I write a 3D string array to file?

  • Simple GUI playing mp3 files

    Hi everyone , i am building a simple GUI playing mp3 files in a certain directory.
    A bug or something wrong with the codes listed down here is very confusing me and makes me desperate. Can anyone help me please ?
    import javax.swing.*;
    import javax.media.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    class PlayMP3Thread
    extends Thread
    private URL url;
    String[] filenames ;
    File[] files ;
    boolean condition=true;
    boolean pause=false;
    int count ;
    public PlayMP3Thread() { }
    public PlayMP3Thread(File[] files)
    //try
              this.files = files;
         filenames = new String[files.length];
         count = -1;
         // this.url = mp3.toURL();
         //catch ( MalformedURLException me )
    public void run()
    try
         while (condition)
              count++;
              if (count > (filenames.length - 1)) {
                        count = 0;
              this.url = files[count].toURL();
    MediaLocator ml = new MediaLocator(url);
    final Player player = Manager.createPlayer(ml);
    /*player.addControllerListener(
    new ControllerListener()
    public void controllerUpdate(ControllerEvent event)
    if (event instanceof EndOfMediaEvent)
    player.stop();
    player.close();
    player.realize();
    player.start();
    catch (Exception e)
    e.printStackTrace();
    public void stops()
    //stop the thread
    condition=false;
    pause=false;
    public void pause()
    while(!pause)
    //pause the thread
    try
    wait();
    catch(Exception ex){}
    pause=true;
    public void resumes()
    while(pause)
    notify();
    pause=false;
    } // end of class MP3Thread
    public class mp3Play extends JFrame {
    JTextField direcText ;
    JFileChooser fc;
    static final String
    TITLE="MP3 PLAYER",
    DIRECTORY="Directory : ",
    BROWSE="Browse...",
    START="Start up",
    STOP="Stop",
    PAUSE="Pause",
    RESUME="Resume",
    EXIT="Exit";
    public static void main(String args[])
         PlayMP3Thread play = new PlayMP3Thread();
         mp3Play pl = new mp3Play();
    } // End of main()
    public mp3Play() {
    setTitle(TITLE);
         Container back = getContentPane();
         back.setLayout(new GridLayout(0,1));
         back.add(new JLabel(new ImageIcon("images/hello.gif")));
         fc = new JFileChooser();
         fc.setFileSelectionMode(fc.DIRECTORIES_ONLY);
         JPanel p1 = new JPanel();
         p1.add(new JLabel(DIRECTORY, new ImageIcon("images/directory.gif"), JLabel.CENTER));
    p1.add(direcText = new JTextField(20));
         JButton browseButton = new JButton(BROWSE, new ImageIcon("images/browse.gif"));
         browseButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showOpenDialog(mp3Play.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
              direcText.setText(fc.getSelectedFile().toString());
              File[] files = (new File(direcText.getText())).listFiles(this);
         p1.add(browseButton);
         back.add(p1);
         JPanel p2 = new JPanel();
              JPanel butPanel = new JPanel();
              butPanel.setBorder(BorderFactory.createLineBorder(Color.black));
              JButton startButton = new JButton(START, new ImageIcon("images/start.gif"));
              startButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
                        PlayMP3Thread play = new PlayMP3Thread(files);
                        play.start();
         butPanel.add(startButton);
         p2.add(butPanel);
         JButton stopButton = new JButton(STOP, new ImageIcon("images/stop.gif"));
         stopButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
              play.stops();
         p2.add(stopButton);
         JButton pauseButton = new JButton(PAUSE, new ImageIcon("images/pause.gif"));
         pauseButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
              play.pause();
         p2.add(pausetButton);
         JButton resumeButton = new JButton(RESUME, new ImageIcon("images/resume.gif"));
              resumeButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                   play.resumes();
         p2.add(resumeButton);
         back.add(p2);
    JButton exitButton = new JButton(EXIT, new ImageIcon("images/exit.gif"));
              exitButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                   System.exit(0);
              p2.add(exitButton);
              back.add(p2);
              addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
              pack();
         setVisible(true);
    }

    Actually I don't know much about fixing technical error or logical error.
    When it compiled , there are 6 errors showed up :
    can't resolve symbol : method listFiles (<anonymous java.awt.event.ActionListener>)
    location: class java.io.File
              File[] files = (new File(direcText.getText())).listFiles(this);
    can't resolve symbol: variable files
                        PlayMP3Thread play = new PlayMP3Thread(files);
    can't resolve symbol: variable play
              play.stops();
    can't resolve symbol: variable play
              play.pause();
    ^
    can't resolve symbol : variable pausetButton
    location: class mp3Play
         p2.add(pausetButton);
    ^
    can't resolve symbol: variable play
                   play.resumes();
    Any suggestions ?

  • To write to a particular position in file

    I have to write objects involved with the diagram in to a XML file.as new components are drawn in the diagram corresponding objects will get added to XML file.For the Object to xml conversion i am using Xstream API.
    In have to insert this portion
    *<Rstmain.gui.TextRectangle>*
      *<x>15</x>*
      *<y>2350</y>*
      *<width>110</width>*
      *<height>63</height>*
      *<rectNo>0</rectNo>*
      *<text__Rectangle>With its distant orbit-50 percent farther from the sun </text__Rectangle>*
    *</Rstmain.gui.TextRectangle>*
    above </temp>
    *<temp>*
    <string-array>
      <string>With its distant orbit-50 percent farther from the sun </string>
      <string>than earth-and slim atmospheric blanket,mars experiences frigid weather conditions.Surface temperatures typically average about -60 d</string>
      <string>egrees Celsius(-76 degrees Fahrenheit)at the equator and can dip to -123 degrees C nea</string>
      <string>r the poles.Only the midday sun at tropic</string>
      <string>al lattitudes is warm enough to thaw ice on occasion,but any liquid water formed in </string>
      <string>this way would evaporate almost </string>
      <string>instantly because of low atmospheric pressure. </string>
    </string-array>
    <int-array>
      <int>55</int>
      <int>189</int>
      <int>276</int>
      <int>318</int>
      <int>403</int>
      <int>436</int>
      <int>485</int>
    </int-array>
    *</temp>*
    <Rstmain.gui.TextRectangle>
      <x>15</x>
      <y>2350</y>
      <width>110</width>
      <height>63</height>
      <rectNo>0</rectNo>
      <text__Rectangle>With its distant orbit-50 percent farther from the sun </text__Rectangle>
    </Rstmain.gui.TextRectangle>I cant use random access file for this because the lines in xml file are not of equal length.
    currently i am using this approach.convert each object separately to xml and then write to a file.
    tempOut = new BufferedWriter(new FileWriter(tempFileXML, true));
                         tempOut.newLine();
                        String txtRectXml = stream.toXML(textRectangle);
                        tempOut.write(txtRectXml);
                        tempOut.close();please suggest some method for solving my problem...

    Thanks...I could solve it by another approach...
    Hope it will be helpful for others
    create Root Node first.tempFileXML is the fileName here.
    String root="temp";
            documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilder = documentBuilderFactory.newDocumentBuilder();
            document = documentBuilder.newDocument();
            rootElement = document.createElement(root);
            document.appendChild(rootElement);
            writeXmlFile(document,tempFileXML);//writing document to file...
             For appending one document to another
    txtXml is string Object comprising a xml document
    txtXml is
    <string-array>
      <string>With its distant orbit-50 percent farther from the sun than</string>
      <string> earth-and slim atmospheric blanket,mars experiences frigid weather conditions.Surface temperatures typically average</string>
      <string> about -60 degrees Celsius(-76 degrees Fahrenheit)at the equator and can dip to -123 degrees C near the poles.</string>
      <string>Only the midday sun at tropical lattitudes is warm </string>
      <string>enough to thaw ice on occasion,but any liquid water formed in this way</string>
      <string> would evaporate almost instantly because of low atmospheric pressure. </string>
    </string-array>
    //Creating new instances of document builder factory
                documentBuilderFactory2 = DocumentBuilderFactory.newInstance();
                documentBuilder2 = documentBuilderFactory.newDocumentBuilder();
               inStream = new InputSource();
               inStream.setCharacterStream(new StringReader(txtXml)); 
               document2=documentBuilder2.parse(inStream);
               document=documentBuilder.parse(tempFileXML);
               document.getFirstChild().appendChild(document.importNode(document2.getDocumentElement(),true));
               writeXmlFile(document,tempFileXML);
                writeXmlFile I got from another forum posting
    public static void writeXmlFile(Document doc, String filename) {
            try {
                // Prepare the DOM document for writing
                Source source = new DOMSource(doc);
                // Prepare the output file
                File file = new File(filename);
                Result result = new StreamResult(file);
                // Write the DOM document to the file
                Transformer xformer = TransformerFactory.newInstance().newTransformer();
                xformer.transform(source, result);
            } catch (TransformerConfigurationException e) {
            } catch (TransformerException e) {
        }

  • Search and replace strings in a file while ignoring substrings

    Hi:
    I have a java program that searches and replaces strings in a file. It makes a new copy of the file, searches for a string in the copy, replaces the string and renames the new copy to the original file, thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but searching for "Topabcd" and replacing it doesnot work because there is a match for "abcd" in a different search scenario. How can I modify the code such that if "abcd" is already searched and replaced then it should not be searched for again or rather search for "abcd" as entire string and not if its a substring of another string.
    In the below code output, all instances of "abcd" and the ones of "Topabcd" are replaced by ABCDEFG and TopABCDEF respectively, whereas according to the desired output, "abcd" should be replaced by ABCDEFG and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
              String find_productstring = "abcd";
              String replacement_productstring = "ABCDEFG";
              compsXml = new FileReader(compsLoc);
              compsConfigFile = new BufferedReader(compsXml);
              File compsFile =new File("file.xml");
              File compsNewFile =new File("file1.xml");
              BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
              while ((compsLine = compsConfigFile.readLine()) != null)
                    new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
                    out.write(new_compsLine);
                    out.write("\n");
                out.close();
                compsConfigFile.close();
                compsFile.delete();
                compsNewFile.renameTo(compsFile);
            catch (IOException e)
            //since "Topabcd" contains "abcd", which is the search above and hence the string "Topabcd" is not replaced correctly
             try
                   String find_producttopstring = "Topabcd";
                   String replacement_producttopstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
                   compsConfigFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
                   BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
                   while ((compsLine = compsConfigFile.readLine()) != null)
                         new_compsLine =compsLine.replaceFirst(find_producttopstring, replacement_producttopstring);
                         out.write(new_compsLine);
                         out.write("\n");
                     out.close();
                     compsConfigFile.close();
                     compsFile.delete();
                     compsNewFile.renameTo(compsFile);
                 catch (IOException e)
            }Thanks a lot!

    Hi:
    I have a java program that searches and replaces
    strings in a file. It makes a new copy of the file,
    searches for a string in the copy, replaces the
    string and renames the new copy to the original file,
    thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but
    searching for "Topabcd" and replacing it doesnot work
    because there is a match for "abcd" in a different
    search scenario. How can I modify the code such that
    if "abcd" is already searched and replaced then it
    should not be searched for again or rather search for
    "abcd" as entire string and not if its a substring of
    another string.
    In the below code output, all instances of "abcd" and
    the ones of "Topabcd" are replaced by ABCDEFG and
    TopABCDEF respectively, whereas according to the
    desired output, "abcd" should be replaced by ABCDEFG
    and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
    String find_productstring = "abcd";
    String replacement_productstring = "ABCDEFG";
    compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    BufferedReader(compsXml);
    File compsFile =new File("file.xml");
    File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    FileWriter("file1.xml"));
    while ((compsLine =
    compsConfigFile.readLine()) != null)
    new_compsLine
    =compsLine.replaceFirst(find_productstring,
    replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
    catch (IOException e)
    //since "Topabcd" contains "abcd", which is
    the search above and hence the string "Topabcd" is
    not replaced correctly
    try
                   String find_producttopstring = "Topabcd";
    String replacement_producttopstring =
    topstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    gFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    dWriter(new FileWriter("file1.xml"));
    while ((compsLine =
    compsLine = compsConfigFile.readLine()) != null)
    new_compsLine
    new_compsLine
    =compsLine.replaceFirst(find_producttopstring,
    replacement_producttopstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
                 catch (IOException e)
    Thanks a lot!I tried the matches(...) method but it doesnt seem to work.
    while ((compsLine = compsConfigFile.readLine()) != null)
    if(compsLine.matches(find_productstring))
         System.out.println("Exact match is found for abcd");
         new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
         else
         System.out.println("Exact match is not found for abcd");
         out.write(compsLine);
         out.write("\n");

  • How to save string in a file with special-chars

    Hello,
    i´m usingthe MD5-llb to create a password.
    Then i  want to save this MD5-string to a file and later read it back abd compare.
    Works perfect with one proplem:
    Some word create a "\r" in the MD5-string and when i save this string to a file and read it back then its read back as a "\n" so that the compare is not working.
    My question is: How can i save a string exactly like it is to somewhere and read it back (also invisible chars)
    For example the word: heinz
    is in MD5: \r\FB^\07\A6\07T\C7\D9\C2\94\AB\C9\1DS\95 (string indicator as codes display)
    when i save the string to a file then i rerad back: \n\FB^\07\A6\07T\C7\D9\C2\94\AB\C9\1DS\95
    I used the "write text file" and "read text file"
    What do i have to use to save and read the same?
    Thx
    Solved!
    Go to Solution.

    I believe an MD5 hash is 16 bytes long. Use the binary read and write file I/O functions and specify the length of the data to be read or written.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How to write the nodevalue back to xml file?

    Hi, Everybody:
    These are two packages I used. javax.xml.parsers.*,org.w3c.dom.*
    Now I use "setNodeValue("abc") to set the node value to "abc". But it is not really saved back into XML file. It only change the node value in memory.
    How to write the changes back to XML file? Thank you very much for your help.
    Michelle

    * Version : 1.00
    * File Purpose : Given the xml file loads into dom and recreate the file with the updated values.
    * Developer : Kashif Qasim : 25/july/04
    * Modify detail :
    import java.lang.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import org.w3c.dom.*;
    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xerces.*;
    public class XMLWriter
    private String displayStrings[] = new String[5000];
    private int numberDisplayLines = 0;
    private Document document;
    //private final Node c;
    public synchronized void displayDocument(String uri,Vector UpdatedValues,String getTaskID)
    try {
    DOMParser parser = new DOMParser();
    parser.parse(uri);
    document = parser.getDocument();
    display(document, "",UpdatedValues);
    } catch (Exception e) {
    e.printStackTrace(System.err);
    ReadXmlConfig objReadXmlConfig = null;
    FileWriter filewriter = null;
    try {
    filewriter = new FileWriter(uri);
    for(int loopIndex = 0; loopIndex < numberDisplayLines; loopIndex++){
    filewriter.write(displayStrings[loopIndex].toCharArray());
    //System.out.println("displayStrings[loopIndex].toCharArray() "+displayStrings[loopIndex].toString());
    //filewriter.write("\n");
    filewriter.close();
    System.gc();
    objReadXmlConfig = new ReadXmlConfig();
    objReadXmlConfig.ITSLog("File updated for "+getTaskID+" succesfully, file is closed now ");
    } catch (IOException e) {
    System.err.println("Caught IOException: " + e.getMessage());
    objReadXmlConfig = new ReadXmlConfig();
    objReadXmlConfig.ITSErrorLog("File updated FAILED for "+getTaskID+". Reason for file error "+e.toString());
    }finally {
    if (filewriter != null) {
    System.out.println("Closing File");
    objReadXmlConfig =null;
    try{
    filewriter.close();
    }catch(IOException e){
    System.err.println("Caught IOException: " + e.getMessage());
    } else {
    System.out.println("File not open");
    private void display(Node node, String indent, Vector UpdtRecs)
    if (node == null) {
    return;
    int type = node.getNodeType();
    NodeList nodeList = document.getElementsByTagName("QueryParm");
    int TotalRecs = UpdtRecs.size();
    switch (type) {
    case Node.DOCUMENT_NODE: {
    displayStrings[numberDisplayLines] = indent;
    displayStrings[numberDisplayLines] +=
    "<?xml version=\"1.0\" encoding=\""+
    "UTF-8" + "\"?>";
    numberDisplayLines++;
    displayStrings[numberDisplayLines] += "\n";
    display(((Document)node).getDocumentElement(), "",UpdtRecs);
    break;
    case Node.ELEMENT_NODE: {
    if(node.getNodeName().equals("QueryParm")) {
    for(int i =0 ; i< nodeList.getLength() ; i++)
    Node nodeQry = nodeList.item(i);
    NamedNodeMap nnp = nodeQry.getAttributes();
    for(int j= 0 ; j < nnp.getLength() ; j++)
    Attr atr = (Attr) nnp.item(j);
    if(atr.getName().equalsIgnoreCase("value_"+(i+1)))
    //System.out.println(atr.getName() +" : " + atr.getNodeValue() );
    atr.setNodeValue(UpdtRecs.get(i).toString());
    displayStrings[numberDisplayLines] = indent;
    displayStrings[numberDisplayLines] += "<";
    displayStrings[numberDisplayLines] += node.getNodeName();
    int length = (node.getAttributes() != null) ?
    node.getAttributes().getLength() : 0;
    Attr attributes[] = new Attr[length];
    for (int loopIndex = 0; loopIndex < length; loopIndex++) {
    attributes[loopIndex] = (Attr)node.getAttributes().item(loopIndex);
    for (int loopIndex = 0; loopIndex < attributes.length; loopIndex++) {
    Attr attribute = attributes[loopIndex];
    displayStrings[numberDisplayLines] += " ";
    displayStrings[numberDisplayLines] += attribute.getNodeName();
    displayStrings[numberDisplayLines] += "=\"";
    displayStrings[numberDisplayLines] += attribute.getNodeValue();
    displayStrings[numberDisplayLines] += "\"";
    displayStrings[numberDisplayLines]+=">";
    numberDisplayLines++;
    NodeList childNodes = node.getChildNodes();
    if (childNodes != null) {
    length = childNodes.getLength();
    indent += " ";
    for (int loopIndex = 0; loopIndex < length; loopIndex++ ) {
    display(childNodes.item(loopIndex), indent,UpdtRecs);
    break;
    case Node.CDATA_SECTION_NODE: {
    displayStrings[numberDisplayLines] = "";
    displayStrings[numberDisplayLines] += "<![CDATA[";
    displayStrings[numberDisplayLines] += node.getNodeValue();
    displayStrings[numberDisplayLines] += "]]>";
    numberDisplayLines++;
    break;
    case Node.TEXT_NODE: {
    displayStrings[numberDisplayLines] = "";
    String newText = node.getNodeValue().trim();
    if(newText.indexOf("\n") < 0 && newText.length() > 0) {
    displayStrings[numberDisplayLines] += newText;
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    break;
    case Node.PROCESSING_INSTRUCTION_NODE: {
    displayStrings[numberDisplayLines] = "";
    displayStrings[numberDisplayLines] += "<?";
    displayStrings[numberDisplayLines] += node.getNodeName();
    String text = node.getNodeValue();
    if (text != null && text.length() > 0) {
    displayStrings[numberDisplayLines] += text;
    displayStrings[numberDisplayLines] += "?>";
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    break;
    if (type == Node.ELEMENT_NODE) {
    displayStrings[numberDisplayLines] = indent.substring(0,
    indent.length() - 4);
    displayStrings[numberDisplayLines] += "</";
    displayStrings[numberDisplayLines] += node.getNodeName();
    displayStrings[numberDisplayLines] += ">";
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    indent += " ";
    public static void main(String args[])
    Vector xmlValue = new Vector();
    xmlValue.add(0,"Kashif");
    xmlValue.add(1,"Qasim");
    //displayDocument("NewMediation.xml",xmlValue);
    <?xml version="1.0" encoding="UTF-8"?>
    <Mediation>
    <Task1>
    <Source>
    <SourceDriver>com.microsoft.jdbc.sqlserver.SQLServerDriver</SourceDriver>
    <SourceConnection>jdbc:microsoft:sqlserver://10.2.1.58:1433;DatabaseName=MTCVB_HDS;</SourceConnection>
    <SourceUser>sa</SourceUser>
    <SourcePassword>sa</SourcePassword>
    <Table>
    <SourceTable>t_Agent</SourceTable>
    <SourceQuery><![CDATA[SELECT SkillTargetID,PersonID,PeripheralID,EnterpriseName,PeripheralNumber,Deleted,TemporaryAgent,AgentStateTrace,ChangeStamp FROM t_Agent where SkillTargetID > {value_1} order by SkillTargetID]]>
    </SourceQuery>
    <SourceParm BusinessRule="" ColumnName="SKILLTARGETID" ColumnNumber="1" DataType="Numeric" DefaultValue="0" Format="mm/dd/yyyy xx:xx:xx XX">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERSONID" ColumnNumber="2" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERIPHERALID" ColumnNumber="3" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="ENTERPRISENAME" ColumnNumber="4" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERIPHERALNUMBER" ColumnNumber="5" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="DELETED" ColumnNumber="6" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="TEMPORARYAGENT" ColumnNumber="7" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="AGENTSTATETRACE" ColumnNumber="8" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="CHANGESTAMP" ColumnNumber="9" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <QueryParm FldName_1="SkillTargetID" FldType_1="Number" value_1="0">
    </QueryParm>
    </Table>
    </Source>
    </Task1>
    </Mediation>
    The QueryParm values are updated thru this code :)
    Hope it helps u ...

  • How to write a return in a text file.

    Hi, i am trying to write diferent lines into a text file, i write strings ending with \r\n but it doesn't work, how could i write in diferent lines?
    Thanks.

    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("myfile.txt")));
    out.println("This is the first line");
    out.println("This is the second line");
    out.flush();
    out.close();Jesper

  • Write Spreadsheet to String Array on another worksheet

    hi,
    is it possible to write spreadsheet to string array but to an added worksheet?
    I am currently writing results to the worksheet, but i want to create another worksheet so that i can put the raw data in.
    is it possible?
    if so, how?
    Best regards,
    Krispiekream
    Solved!
    Go to Solution.

    Sorry,
    i guess i attached the wrong picture.
    i currently have this.
    I read from a spreadsheet.
    and analysis certain row and column, then do calculation and write the results to a new spreadsheet.
    it is working fine.
    but as an option. i wanted to "read all the data from the spreadsheet as the previous image" and then write those data to the same new spreadsheet file but in a different worksheet.
    Best regards,
    Krispiekream

  • Replace String within a file

    i want to replace a string within a file
    there is NO GUI ..
    i take in mind two approaches
    1) hold the file content in memory
    and rewrite the file
    2) write the new data to a new file.
    and then rewrite the original file
    any better ideas

    sorry, no..
    Your idea is kinda right if small file is within existance..
    Small file.
    Why not just use the filereader and filewriter? read the docs upon that
    Large file
    Why wont you create a string buffer, and parse the file chunk by chunk into that buffer one at a time. Then of course you saved the position of the character or word you wanted to apend or write, and you just write it back to that area.

  • Replace string in a file

    I want a java program can replace string in a file with given string.
    for example,
    my file is
    abc 100
    aaa 110
    ded 123
    replace aaa with mmm.
    my codes is reading line by line and looking for aaa ,if read_line.index("aaa")> -1,then write mmm and aaa.substring
    Do you have ant other solutions?is there any file class method I can use?
    cheers.

    String content = <get file content>;
    String newContent = content.replaceAll( "aaa", "I get my homework on java.sun.com" );
    if( !newContent.equals(content) )
       <rewrite file contents>

  • Search for a String in a File?

    hi all
    is there a methid in java with which i can open a file and
    search for a specified string in the file? i also have to
    replace the String then.
    Thanks angela

    There is no magic method that can do all this for you. First you need to create an inputstream from the file you want to read. Then you can read it (without necessarily store the whole file in memory), until you find a match. If you want to replace the string with another string of the same length, you can use RandomAccessFile. If not, then you will have to move all the rest of the file forward or backwards when you replace the string, or write the whole file modified to a new file and then delete the old file before you rename the new updated file.
    Or you can depending on what you do, append changes to the end of the file, more or less like what is done with Word documents. And then only once in a while update the file with all the appended changes.

  • Transfer string to unix file

    Hi Gurus,
    I am converting data in an internal table (consisting of 5000 records) into XML string using CALL TRANSFORMATION. All data is stored in XML format in a variable of type STRING.
    I am trying to write this data in a Unix file using TRANSFER statement.
    The problem is all data is not copied into the file!
    Can anyone suggest a suitable solution so that complete data in the string variable will be reflected in the file?
    Regards,
    Jack

    Hi,
    If you are opening the file in text mode, your itab fields have to be character type fields. So define another itab with fields of character type with lengths defined as per your output requirements.
    You have understand that if you have floating, decimal fields, currency or quantity fields in your itab, they are know to SAP only, once you try to download such records, converting them into character form needs to happen.
    Did you try the binary mode with your 'open dataset' statement?
    Srinivas

  • How to output strings to a file faster.

    Hi,
    I need to output large among strings to a file. The requirement is that the time of file processing shall be as short as possible. So I implemented as following:
    Define a StringBuffer and append all the strings first. Open file. Using BufferedWrite to write into it. Close file.
    It works. But sometimes I got OutOfMemoryException if there are to many strings. To avoid this I increased memory.
    I wonder if there is any other solution to do it without increasing memory?
    Saga

    Hi!
    As I understand your problem, you have two possible solutions.
    1. change your approach to somthing like appanding only a fixed number of strings to a stringbuffer and write it to the file (appending each time your write the buffer), clear the stringbuffer. This will prevent from OutOfMenory exceptions but increase file activity.
    2. append the strings directly to the file to prevent OutOfMenory exceptions.This way you have short but frequent file activity.
    Hope this helps
    Timo

Maybe you are looking for