Exception in thread "main" java.lang.NullPointerException
at com.jany.controllertest.UploadTest.upload(UploadTest.java:61)
at com.jany.controllertest.UploadTest.main(UploadTest.java:44)
System.out.println(r.toString());
public void upload() throws IOException {
try {
//调用put方法上传
Response res = uploadManager.put(FilePath, key, getUpToken());
//打印返回的信息
System.out.println(res.bodyString());
} catch (QiniuException e) {
Response r = e.response;
// 请求失败时打印的异常的信息
System.out.println(r.toString());//*这行空指针错误*
try {
//响应的文本信息
System.out.println(r.bodyString());
} catch (QiniuException e1) {
//ignore
}
}
}
你试试这个上传代码: