简体   繁体   中英

Mule variable in MEL as String

i have an expression bellow to read a file from resources :

#[Thread.currentThread().getContextClassLoader().getResourceAsStream('abc.txt')]

it worked fine, but i want to use a variable like this one:

#[Thread.currentThread().getContextClassLoader().getResourceAsStream(flowVars['fileName'])]

it does not work,

  1. how can i make it work like the first one MEL ?
  2. how can i read a file in absolute path "D://input/abc.txt" using MEL ?

Thanks for helps.

resolved

  1. use flowVars.filename instead of flowVars['fileName'] it worked, but i can't get it, i use logger with this MEL #[flowVars['filename']] and it work too but in the second MEL it failed.

1) You are using a different case with the two different approaches. Variable names are case sensitive.

2) Just use a FileInputStream:

 #[new FileInputStream("path")]

Or even better maybe to use the File transport/Mule Requester Module.

试试这个,用变量名代替关键字“ flowVars”

#[Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM