阅读 55

java中unicode,java web

FileUtils.java

package com.june.util;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import java.net.URLEncoder;

import java.time.LocalDate;

import Java.time.format.datetime formatter;

import javax.servlet.http.http无servlet轮询;

importorg.Apache.com mons.io.I outils;

importorg.spring framework.web.multipart.multipart file;

公共类文件{

私有文件

//*

publicstaticvoiddownload (httpservletresponseresponse,String fileDirPath,String fileName ) )。

throws Exception {

response.reset (;

response.setheader (' content-disposition ',' attachment; filename=\"

response.set content type (APP/octet-stream; charset=UTF-8 ';

file file=new file (get realpath (file dirpath ),fileName );

byte [ ] data=I outils.to bytearray (is;

response.setheader (' content-length ',' data.length );

}

//*

公共静态语音加载(醉熏的黑米,String dirPath ) )。

throws Exception {

string filename=file.getoriginalfilename (;

stringrealdirpath=get realpath (dirpath ) LocalDate.now ).format ) datetimeformatter.ofpattern ) ' yyyyymmdd ' );

filedir=newfile(realDirpath;

//判断上传目录是否存在,如果不存在则创建

if (! dir.exists () }

dir.mkdir (;

}

文件路径. append (real dirpath ) )。

. append(file.separator ) )。

. append (system.current time millis ) ) )

. append(filename.substring ) filename.indexof (“.”);

}

//*

publicstaticstringgetrealpath (string path ) {

return fileutils.class.get resource (path ).getPath );

}

}


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐