本文整理汇总了Java中org.apache.commons.io.FileUtils.getTempDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getTempDirectory方法的具体用法?Java FileUtils.getTempDirectory怎么用?Java FileUtils.getTempDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getTempDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@PostConstruct
public void setup() {
if (dataPath == null || dataPath.isEmpty()) {
// init dataPath to platform dependent value
if (OsUtils.isUnix() || OsUtils.isMac()) {
dataPath = dataPathFallbackNix;
} else if (OsUtils.isWindows()) {
dataPath = dataPathFallbackWin;
} else {
logger.warn("fallback value for datadir not defined for this platform. Falling back to tmp dir");
dataPath = FileUtils.getTempDirectory() + File.separator + "toscana";
}
}
dataDir = new File(dataPath);
dataDir.mkdirs();
logger.info("Data directory is {}", dataDir.getAbsolutePath());
if (!dataDir.exists()) {
logger.error("Failed to create data directory");
}
}
示例2: uploadAvatar
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public FileObject uploadAvatar(UploadFileRequest uploadFileRequest,
HttpServletRequest request,
HttpServletResponse response) throws IOException {
validate(uploadFileRequest);
MultipartFile multipartFile = HttpMultipartUtils.resolveMultipartFile(request);
if (multipartFile == null || multipartFile.isEmpty()) {
throw new FileStorageException("The multipart of http request is required.");
}
FileStorageRequest fileStorageRequest = buildFileStorageRequest(multipartFile, uploadFileRequest);
File tempFile = new File(FileUtils.getTempDirectory(), UUID.randomUUID() + ".tmp");
multipartFile.transferTo(tempFile);
File resizedTempFile = new File(FileUtils.getTempDirectory(), UUID.randomUUID() + ".tmp");
ImageUtils.zoomBySquare(tempFile, resizedTempFile, 128, true);
return doUpload(fileStorageRequest, resizedTempFile);
}
示例3: getTmpFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static File getTmpFile() throws IOException {
File tmpDir = FileUtils.getTempDirectory();
if (!tmpDir.exists()) {
tmpDir.mkdirs();
}
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
示例4: getTmpFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
示例5: getTmpFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000.0D + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
示例6: getLocalTempFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private File getLocalTempFile(String filename) {
return new File(FileUtils.getTempDirectory(), UUID.randomUUID().toString().substring(0, 10) + "-" + filename);
}
示例7: FileStore
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
*
* Constructs a new {@link FileStore}.
*
* @throws IOException due to problems during the rootBucket creation
*/
public FileStore() throws IOException {
this(new File(FileUtils.getTempDirectory(), "s3mockFileStore" + new Date().getTime()));
}