标签:文件路径 public orm str form iter ring class ram
/**
* 将文件写入到本地磁盘
* @param dirPath 目录路径
* @param fileName 文件名,包含文件后缀
* @param buffer 文件
* @return 文件路径
*/
public String writeToFile(String dirPath, String fileName, String buffer) {
String NCHome = RuntimeEnv.getInstance().getProperty(RuntimeEnv.SERVER_LOCATION_PROPERTY);
dirPath = NCHome + File.separator + "upload";
File file = new File(dirPath);
if (!file.exists()) {
file.mkdirs();
}
SimpleDateFormat df = new SimpleDateFormat("_yyyy_MM_dd_HHmmss");
fileName = fileName + df.format(new Date());
String filePath = dirPath + File.separator + fileName;
try {
OutputStream out = new FileOutputStream(filePath);
Writer writer = new java.io.OutputStreamWriter(out, "UTF-8");//UTF-8,GB2312
writer.write(buffer.toString());
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
return filePath;
}
标签:文件路径 public orm str form iter ring class ram
原文地址:https://www.cnblogs.com/yazhouasu/p/14889029.html