fileinfo.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 131 行
JAVA
131 行
package com.redmoon.kit.util;import java.io.*;public class FileInfo { public String name, contentType, fieldName; public long size = 0; public String ext = ""; public String diskName = ""; public FileInfo() { } public String getName() { return name; } public String getExt() { return ext; } public String getFieldName() { return this.fieldName; } public boolean write(String savepath) { return write(savepath, false); } public boolean write(String savepath, boolean isRand) { String rname = ""; if (isRand) rname = FileUpload.getRandName() + "." + ext; return write(savepath, rname); } public boolean writeToPath(String fullPath) { boolean re = false; re = CopyFile(tmpFilePath, fullPath); return re; } public boolean write(String savepath, String newname) { boolean re = false; if (savepath == null) savepath = ""; File f = new File(savepath); if (!f.isDirectory()) { f.mkdirs(); } if (newname == null || newname.equals("")) newname = name; diskName = newname; re = CopyFile(tmpFilePath, savepath + newname); return re; } public static boolean CopyFile(String filePathSrc, String filePathDes) { boolean re = false; File fSrc = new File(filePathSrc); if (!fSrc.exists()) return false; try { if (fSrc.isFile()) { FileInputStream input = new FileInputStream(fSrc); FileOutputStream output = new FileOutputStream(filePathDes); byte[] b = new byte[1024 * 5]; int len; while ((len = input.read(b)) != -1) { output.write(b, 0, len); } output.flush(); output.close(); input.close(); re = true; } else System.out.print("debug:" + filePathSrc + "已不存在!"); } catch (IOException e) { System.out.print(e.getMessage()); } return re; } public void setDiskName(String diskName) { this.diskName = diskName; } public String getDiskName() { return diskName; } public long getSize() { return size; } public String getContentType() { return contentType; } public String getTmpFilePath() { return tmpFilePath; } public void setTmpFilePath(String tmpFilePath) { this.tmpFilePath = tmpFilePath; } private String tmpFilePath;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?