Hi,
To append data to a file in Java you can use FileWriter with the second parameter in the constructor set true. You can try this Java service to append a String to a file, if the file does not exists it is created.
try {
IDataSharedCursor idc = pipeline.getSharedCursor();
FileWriter writer = null;
BufferedWriter buffer = null;
String filename = null;
String data = null;
if (idc.first("filename"))
filename = (String) idc.getValue();
else
throw new ServiceException("appendFile: filename is missing");
if (idc.first("data"))
data = (String) idc.getValue();
else
throw new ServiceException("appendFile: data is missing");
// this is where you tell the FileWriter to append.
writer = new FileWriter(filename, true);
buffer = new BufferedWriter(writer);
buffer.write(data);
buffer.close();
writer.close();
idc.destroy();
} catch (Exception e) {
throw new ServiceException(e);
}
#Integration-Server-and-ESB#Flow-and-Java-services#webMethods