簡體   English   中英

如何在spring集成中獲取文件的完整路徑?

[英]How to get full path of the file in spring integration?

我是Spring Integration的新手。 我有以下代碼。 我在我的系統的一個文件夾中放置了一個文本文件,並且我已經配置了入站通道適配器,如下所示:

<int-file:inbound-channel-adapter channel="filesInChannel"
    directory="file:${java.io.tmpdir}/input" auto-create-directory="true"  >

    <int:poller id="poller" fixed-delay="1000" />
</int-file:inbound-channel-adapter>

<int:channel id="filesInChannel"> </int:channel>

我的問題是來自頻道( filesInChannel )我怎么才能知道文件名包括它的絕對路徑?

例如:我的文件位於C:\\someFolder\\some.txt

從頻道我應該走上路徑。

一旦你擁有了fileName,你想做什么?

消息有效負載是java.io.File因此您只需使用表達式payload.absolutePath ,例如:

<header-enricher...>
   <header name="foo" expression="payload.absolutePath" />
</header-enricher>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM