360浏览器下载含有中文的文件名与其它浏览器的区别

本文提供了解决使用360浏览器下载文件时,文件名出现乱码的问题解决方案。通过代码示例展示了如何根据浏览器类型调整文件路径编码,确保下载的文件名正确无误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

360浏览器下载还是有点小问题!不过不影响下载   名称那里是乱码,下载后的名字从:http://localhost/webs/download.action?path=uploadfile/ppt/5.中经网统计数据库O.ppt 下的5.中经网统计数据库O.ppt;

那位朋友有更好地办法将名称也不是乱码且能下载的,请联系我哟!!! email:weipeng@ssreader.cn    共同进步!!!

String str = ServletActionContext.getRequest().getHeader("USER-AGENT").toLowerCase();
        if (str.indexOf("360se") > -1) {
            path = new String(path.getBytes("iso-8859-1"), "gb2312");
        } else {
            path = new String(path.getBytes("iso-8859-1"), "utf8");
        }
        fullname = path.substring(path.lastIndexOf("/") + 1);
        
        File dst = new File(ServletActionContext.getServletContext().getRealPath("/"));
        String dstin = dst.toString();
        String down = dstin + "\\" + path;
        java.io.File file = new File(down);
        if (!file.exists()) {
            java.io.File f = new File(down.substring(0, down.lastIndexOf("/")));
            if (!f.exists()) {
                f.mkdirs();
            }
            file.createNewFile();
        }
        
        FileInputStream in = null;
        try {
            in = new FileInputStream(down);
            
        } catch (Exception e) {
            System.out.println("Error!");
            e.printStackTrace();
        }
        return in;
    }

转载于:https://www.cnblogs.com/weipeng/archive/2012/07/05/2577557.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值