我正在尝试使用Camel处理潜在的大文件,并且担心它们在Camel的主体中"适合" Message.有没有办法可以将文件的名称(路径)作为消息正文传递,然后在处理器中使用它来从磁盘读取?
您只需传入一个java.io.File实例即可.这基本上是Camel文件组件自身的作用(尽管它放在WrappedFile中,因为它与ftp组件共享代码).
您当然也可以将文件名作为String存储,然后从处理器访问该文件,或者通过
String name = exchange.getIn().getBody(String.class);
File file = new File(name);
...
FileInputStream fis = new FileInputStream(file);
// read the file from the stream, etc.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4304 次 |
| 最近记录: |