ECMAscript a/b路径转a\\b

路径地址转换

 1 var flowFile = session.get();
 2 if(flowFile != null) {
 3     try {
 4         var path = flowFile.getAttribute('要转换路径')
 5         var attrName = flowFile.getAttribute('存储属性名')
 6         flowFile = session.putAttribute(flowFile, attrName, path.replace(/\//g,"\\"))
 7         session.transfer(flowFile, REL_SUCCESS)
 8     } catch(e) {
 9         session.transfer(flowFile, REL_FAILURE)
10     }
11 }

 

posted @ 2021-07-22 14:25  木章  阅读(35)  评论(0编辑  收藏  举报