Announcement Announcement Module
Collapse
No announcement yet.
to simple: delete a file using just one Spring Integration element [Help] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • to simple: delete a file using just one Spring Integration element [Help]

    Hi everybody;

    Actually i'm using an int:service-activator which calls a java method in order to delete a txt file. This solution is not elegant and I would like do the deletion without use any java class, something like:
    Code:
    <file:something id="delFile" channel="toDel" directory="path"  delete-source-files: "true"/>
    is it possible to do something like that?

    Thanks!

  • #2
    If the payload is a java.io.File...

    Code:
    <int:service-activator input-channel="toDel" expression="payload.delete()" output-channel="nullChannel" />
    If you want to test success/failure to delete, route the output to a channel - the payload will be a Boolean (result of java.io.File.delete()).

    Comment


    • #3
      Thanks for the answer, but in the payload is not the file, the only thing related with the file is stored in the header and is a peace of the name of the file. To create the file i did the following:

      Code:
      <file:outbound-channel-adapter id="fileout" channel="toStart" directory="${temporal.path}"  filename-generator-expression="headers[messageId].substring(3)+'.txt'"/>
      The idea would be something like that:
      Code:
      <int:service-activator id="deleteFile" input-channel="todeleteFile" output-channel="outscreen"
      		expression="getResource(${temporal.path}+headers[messageId].substring(3)+'.txt').delete()"/>
      Thank!
      Last edited by uzor; Feb 16th, 2012, 10:43 AM.

      Comment

      Working...
      X