1、添加QP指令对应的接口,修改E0,74,QQ等指令相关的接口。2、添加农行北分海淀支行-军队资金集中收付系统测试类。3、添加打印工具类及文件读取写入工具类
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.sunyard.util;
|
||||
|
||||
import com.sunyard.SydApiException;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* 从文件中读取数据
|
||||
* @param path
|
||||
* @return
|
||||
* @throws SydApiException
|
||||
*/
|
||||
public static byte[] getDataFromFile(String path) throws SydApiException {
|
||||
|
||||
File file = new File(path);
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
throw new SydApiException("该文件不存在", -27);
|
||||
}
|
||||
|
||||
BufferedInputStream bis = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(file));
|
||||
baos = new ByteArrayOutputStream(1024);
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
int size = 0;
|
||||
|
||||
while ((size = bis.read(buf)) != -1) {
|
||||
baos.write(buf, 0, size);
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将字符串数据存储到文件中
|
||||
* 如果文件不存在则自动创建
|
||||
* @param path 文件路径
|
||||
* @param data 数据
|
||||
*/
|
||||
public static void printDataToFile(String path, String data) {
|
||||
OutputStreamWriter osw = null;
|
||||
try {
|
||||
osw = new OutputStreamWriter(new FileOutputStream(path));
|
||||
|
||||
osw.write(data);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user