Java Code Examples for org.apache.commons.io.FileUtils.getTempDirectory()

The following are Jave code examples for showing how to use getTempDirectory() of the org.apache.commons.io.FileUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: TOSCAna   File: Preferences.java   View Source Code Vote up 6 votes
@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");
    }
}
 
Example 2
Project: spring-backend-boilerplate   File: AttachmentRestSupportImpl.java   View Source Code Vote up 6 votes
@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);
}
 
Example 3
Project: xmanager   File: DefaultFileManager.java   View Source Code Vote up 5 votes
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);
}
 
Example 4
Project: framework   File: StorageManager.java   View Source Code Vote up 4 votes
private static File getTmpFile() {
	File tmpDir = FileUtils.getTempDirectory();
	String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
	return new File(tmpDir, tmpFileName);
}
 
Example 5
Project: solo-spring   File: StorageManager.java   View Source Code Vote up 4 votes
private static File getTmpFile() {
	File tmpDir = FileUtils.getTempDirectory();
	String tmpFileName = (Math.random() * 10000.0D + "").replace(".", "");
	return new File(tmpDir, tmpFileName);
}
 
Example 6
Project: easycms   File: StorageManager.java   View Source Code Vote up 4 votes
private static File getTmpFile() {
	File tmpDir = FileUtils.getTempDirectory();
	String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
	return new File(tmpDir, tmpFileName);
}
 
Example 7
Project: hdfs-shell   File: EditCommands.java   View Source Code Vote up 4 votes
private File getLocalTempFile(String filename) {
    return new File(FileUtils.getTempDirectory(), UUID.randomUUID().toString().substring(0, 10) + "-" + filename);
}
 
Example 8
Project: S3Mock   File: FileStore.java   View Source Code Vote up 2 votes
/**
 *
 * 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()));
}