Writing String Data to a File

I have a Java agent that writes an XML string to a log file with the following code:

LogAccessor.getLogger().logText(stringXML);

I’m now interested in writing this XML string to a file in UTF-8 format. The following code is intended to do this, but only writes the first line of the XML string to the file:

File file = new File (“test.fo”);

// Create a file if it does not exist;

boolean success = file.createNewFile();

if (success) {

// File did not exist and was created.

} else {

// File already exists.

}

} catch (IOException e) {

}

try {

 Writer out = new BufferedWriter(new OutputStreamWriter

 (new FileOutputStream("test.fo"),"UTF8"));

 out.write(stringXML);	

 out.close();

} catch (UnsupportedEncodingException e) {

} catch (IOException e) {

}

I’d appreciate any suggestions on how this code might be modified to write the entire XML string to a file in UTF-8 format.

Thanks.

Subject: Writing String Data to a File

Here’s an example of what I’ve described:

The XML string is thousands of characters in length. However, After opening the output file with the vi editor, only the following line appears plus the message “A line cannot be longer than 2048 characters.”

<?xml version="1.0" encoding="UTF-8"?>

Here’s an excerpt of the XML string …

<?xml version="1.0" encoding="UTF-8"?>

<fo:root xmlns:fo=“http://www.w3.org/1999/XSL/Format”>fo:layout-master-set<fo:simple-page-master margin-bottom=“0.0in” margin-right=“0.0in” margin-top=“0.0in” margin-left=“0.0in” page-height=“11in” page-width=“8.5in” master-name=“Letter-p-1”><fo:region-body margin-bottom=“1.2in” margin-top=“1.5in” margin-right=“0.4in” margin-left=“1.3in” column-count=“1”/><fo:region-before extent=“1.3in”/><fo:region-start extent=“1.3in”/><fo:region-after extent=“1.2in”/><fo:region-end

Is there some means of writing all of the XML data to the output file?

Thanks.