Commit 7d8e6adb by chengzhuoshen

修改读取文件路径代码

parent 247ac523
......@@ -15,6 +15,7 @@ import javax.xml.datatype.XMLGregorianCalendar;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.text.ParseException;
import java.util.*;
......@@ -380,7 +381,13 @@ public abstract class AbstractMx2SwiftDtoCreator implements Mx2SwiftDtoCreator{
*/
protected void readPropertyFile(String fileName) {
try {
File propertyFile = new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\template\\mx2swiftdto\\"+ fileName);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
URL resource = contextClassLoader.getResource("template/mx2swiftdto/"+fileName);
if (resource == null) {
resource = AbstractMx2SwiftDtoCreator.class.getClassLoader().getResource("template/mx2swiftdto/"+fileName);
}
File propertyFile = new File(resource.getPath());
List<String> properties = FileUtils.readLines(propertyFile);
if (properties.size() > 0) {
for (String property : properties) {
......
......@@ -13,6 +13,7 @@ import com.brilliance.swift.vo.common.ChargeInfo;
import org.dom4j.Document;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -89,7 +90,7 @@ public class Mx2SwiftDtoCCTCreator extends AbstractMx2SwiftDtoCreator {
if (StringUtil.isNotEmpty(outputFilePath)) {
customerCreditTransfer.write(new File(outputFilePath));
}
} catch (Exception e) {
} catch (IOException e) {
throw new SwiftException("ERROR", e.getMessage());
}
}
......
......@@ -19,16 +19,18 @@ public class Test {
public static void main(String[] args) throws IOException {
String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml"));
File file = new File("D:\\test\\MxPacs00800102.xml");
String xmlStr = FileUtils.readFileToString(file);
//String xmlStr = FileUtils.readFileToString(new File(System.getProperty("user.dir")+"\\swiftCore\\src\\main\\resources\\swiftXml\\MxCamt05400108_CREDIT.xml"));
//Map<String, Object> extraMap = new HashMap<>();
//extraMap.put("bnkBic", "BANKANC0XXX");//发报
//extraMap.put("bnkBic", "FOOBARC0");//收报
//Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, extraMap);
//maps.forEach((k, v) -> System.out.println(k + "=" + v));
// extraMap.put("bnkBic", "FOOBARC0");//收报
Map<String, String> maps = SwiftTransfer.mx2MtMap(xmlStr, null);
maps.forEach((k, v) -> System.out.println(k + "=" + v));
//String gson = SwiftTransfer.mx2Gson(xmlStr);
//System.out.println(gson);
Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
maps.forEach((k, v) -> System.out.println(k + "=" + v));
//Map<String, String> maps = SwiftTransfer.mx2Map(xmlStr);
// maps.forEach((k, v) -> System.out.println(k + "=" + v));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment