如何配置 FlatFileItemWriter 将文件输出到 ByteArrayRecource? [英] how to configure FlatFileItemWriter to output the file to a ByteArrayRecource?

查看:30
本文介绍了如何配置 FlatFileItemWriter 将文件输出到 ByteArrayRecource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,部署服务器不允许应用程序将文件输出到它的文件系统......所以我想要做的是将 FlatFileItemWriter 配置为输出结果文件到静态 Resource 属性(多线程在这里不是问题).我的当前代码是

I have a situation in which the deployment server doesn't allow the application to output files to its file system ... so what i'm trying to do is to configure the FlatFileItemWriter to output the result file to a static Resource property (multi Threading is not an issue here ) . the current code i have is

...
flatFileItemWriter.setResource(new FileSystemResource("outputBatch/users.csv"));
...

有什么办法可以将此文件输出到稍后访问的静态资源属性,例如 ByteArrayResourceInMemoryResource .提前致谢

is there any way i can output this file to a static Resource property to be accessed later, for example ByteArrayResource or InMemoryResource . thanks in advance

推荐答案

FlatFileItemWriter 旨在将项目写入平面文件或表示文件的可写 Resource.这是其 Javadoc:

The FlatFileItemWriter is designed to write items to a flat file or a writable Resource that represents a file. Here is an excerpt from its Javadoc:

The location of the output file is defined by a Resource and must represent a writable file.

因此,在您的情况下,您需要使用将项目写入内存资源的自定义编写器.

So in your case, you need to use a custom writer that writes items to an in-memory resource.

这篇关于如何配置 FlatFileItemWriter 将文件输出到 ByteArrayRecource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆