xiaoyong931011
2022-07-28 363c0f2d5ac2cec13e28bcba4f46f272dff448dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cc.mrbird.febs.pay.util;
 
import java.io.InputStream;
import java.io.InputStreamReader;
 
public class HttpResponse {
    private InputStream inputStream;
    private String fileName;
    private String contentType;
    private int contentLength;
    public String getFileName() {
        return this.fileName;
    }
 
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
 
    public InputStream getInputStream() {
        return this.inputStream;
    }
 
    public void setInputStream(InputStream inputStream) {
        this.inputStream = inputStream;
    }
 
    public String getContentType() {
        return this.contentType;
    }
 
    public void setContentType(String contentType) {
        this.contentType = contentType;
    }
 
    public int getContentLength() {
        return this.contentLength;
    }
 
    public void setContentLength(int contentLength) {
        this.contentLength = contentLength;
    }
 
    public String getDataString() {
        StringBuilder sb = new StringBuilder();
        try {
            InputStreamReader isr = new InputStreamReader(getInputStream(), "utf-8");
            char[] cbuf = new char[1024];
            int hasRead = 0;
            while ((hasRead = isr.read(cbuf)) > 0) {
                sb.append(cbuf, 0, hasRead);
            }
            isr.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}