File f = fileManager.getFile(newSeal.getSealFileId());
String path = SystemEnvironment.getSystemTempFolder();
File newfile = new File(path + File.separator + x.getFilename());
EcontractUtil.copyFile(f, newfile);
SystemEnvironment类
private static String systemTempFolder = null;
private static String accessPatterns = "Local";
private static String indexFilePath = null;
private static String baseFolder = null;
public static String getSystemTempFolder() {
if (isBlank(systemTempFolder)) {
String filepath = null;
if (accessPatterns.equals("Remote")) {
if (indexFilePath != null && !indexFilePath.isEmpty()) {
filepath = indexFilePath + "/temporary";
} else {
filepath = baseFolder + "/index/temporary";
}
} else {
filepath = SystemProperties.getInstance().getProperty("ctp.temporary.folder");
}
systemTempFolder = getCanonicalPathAndCreate(filepath);
}
return systemTempFolder;
}
private static String getCanonicalPathAndCreate(String filepath) {
return getCanonicalPath(filepath, true);
}
private static String getCanonicalPath(String filepath, boolean isCreate) {
if (isBlank(filepath)) {
return null;
} else {
File f = new File(filepath);
try {
File fc = f.getCanonicalFile();
if (isCreate) {
fc.mkdirs();
}
return fc.getAbsolutePath();
} catch (IOException var4) {
return filepath;
}
}
}
private static boolean isBlank(String str) {
return str == null || str.length() == 0;
}
EcontractUtil类
public static void copyFile(File oldfile, File newfile) throws Exception {
FileInputStream in = new FileInputStream(oldfile);
FileOutputStream out = new FileOutputStream(newfile);
byte[] buff = new byte[1024];
int n = 0;
while ((n = in.read(buff)) != -1) {
out.write(buff, 0, n);
}
out.flush();
in.close();
out.close();
}