This commit is contained in:
Mark Fisher
2008-12-12 19:17:01 +00:00
parent d75e1d9093
commit 228f3a4258
2 changed files with 48 additions and 6 deletions

View File

@@ -73,15 +73,19 @@ public class FileWritingMessageHandler implements MessageHandler {
Assert.notNull(payload, "message payload must not be null");
File file = new File(parentDirectory, this.fileNameGenerator.generateFileName(message));
try {
if (payload instanceof byte[]) {
FileCopyUtils.copy((byte[]) payload, file);
}
else if (payload instanceof File) {
if (payload instanceof File) {
FileCopyUtils.copy((File) payload, file);
}
else {
else if (payload instanceof byte[]) {
FileCopyUtils.copy((byte[]) payload, file);
}
else if (payload instanceof String) {
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), this.charset);
FileCopyUtils.copy(payload.toString(), writer);
FileCopyUtils.copy((String) payload, writer);
}
else {
throw new IllegalArgumentException(
"unsupported Message payload type [" + payload.getClass().getName() + "]");
}
}
catch (Exception e) {