whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
59
60
package com.fgkj.actions;
 
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
 
public class FileDownloadAction extends ActionUtil{
    private String PageName;
    private String filename; 
    private String arr_Td;
    private String arr_Th;
    private String contentLength;
    //返回一个输入流,作为一个客户端来说是一个输入流,但对于服务器端是一个 输出流  
    public InputStream getDownloadFile(){
        InputStream is = null;
        filename = "spket-1.6.23.jar";
        try {
            is = new FileInputStream("D:\\spket-1.6.23.jar");
            //解解乱码  
            this.filename = new String(this.filename.getBytes("GBK"),"ISO-8859-1"); 
            this.contentLength = is.available()+"";
            System.out.println(contentLength);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("返回输入流"+is);
        return is;  
    }
 
    public String getFilename() {
        return filename;
    }
 
    public void setPagename(String pagename) {
        PageName = pagename;
    }
 
    public void setArr_Td(String arr_Td) {
        this.arr_Td = arr_Td;
    }
 
    public void setArr_Th(String arr_Th) {
        this.arr_Th = arr_Th;
    }
 
    public String getContentLength() {
        return contentLength;
    }
 
    public void setContentLength(String contentLength) {
        this.contentLength = contentLength;
    }
 
}