接口对接的一系列问题
查找的资料
若依的java对post模拟请求
发送 POST 请求出现异常!
读取.properties文件问题
java模拟前端post请求获取数据,一开始就报错,链接param含有-,在输出中为?。但是在Java中直接写链接就没有这个问题,那就是读取.properties文件ProPertiesUtil 的问题,把字节流改为了字符流,在通过ProPertiesUtil 方法获取链接就正常了。
public class ProPertiesUtil {
private static ProPertiesUtil configManager;
private static Properties properties;
//通过私有构造方法读取配置文件里的信息
private ProPertiesUtil(String path){
//String path="test.properties";
//读取数据
InputStream is= ProPertiesUtil.class.getClassLoader().getResourceAsStream(path);
//通过Properties获取
properties=new Properties();
try {
// 原来的字节流
// properties.load(is);
// 现在的字符流
//这样输入的时候就可以不是一个一个字节读,而是一个一个字符读,再加上是个Buffer,效率会高很多。
BufferedReader bf = new BufferedReader(new InputStreamReader(is));
properties.load(bf);
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}