本文整理了Java中org.apache.commons.io.FileUtils.getTempDirectory()
方法的一些代码示例,展示了FileUtils.getTempDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getTempDirectory()
方法的具体详情如下:
包路径:org.apache.commons.io.FileUtils
类名称:FileUtils
方法名:getTempDirectory
[英]Returns a File representing the system temporary directory.
[中]返回表示系统临时目录的文件。
代码示例来源:origin: hs-web/hsweb-framework
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
代码示例来源:origin: mpetazzoni/ttorrent
public TempFiles() {
myCurrentTempDir = ourCurrentTempDir;
if (!myCurrentTempDir.isDirectory()) {
throw new IllegalStateException("Temp directory is not a directory, was deleted by some process: " + myCurrentTempDir.getAbsolutePath() +
"\njava.io.tmpdir: " + FileUtils.getTempDirectory());
}
myShutdownHook = new Thread(new Runnable() {
public void run() {
myInsideShutdownHook = true;
cleanup();
}
});
Runtime.getRuntime().addShutdownHook(myShutdownHook);
}
代码示例来源:origin: apache/geode
@Override
/**
* We don't expect any callers to call this code, but just in case, implementation is provided for
* backward compatibility
*
* @deprecated since 1.4 use processCommand(String commandString, Map<String, String> env,
* List<String> stagedFilePaths)
*/
public String processCommand(String commandString, Map<String, String> env, Byte[][] binaryData) {
// save the binaryData into stagedFile first, and then call the new api
File tempDir = FileUtils.getTempDirectory();
List<String> filePaths = null;
try {
filePaths = CliUtil.bytesToFiles(binaryData, tempDir.getAbsolutePath());
return bridge.processCommand(commandString, env, filePaths);
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
// delete the staged files
FileUtils.deleteQuietly(tempDir);
}
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testGetTempDirectory() {
final File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
assertEquals(tempDirectory, FileUtils.getTempDirectory());
}
代码示例来源:origin: apache/incubator-pinot
File tempDir = File.createTempFile(SEGMENT_UPLOADER, null, FileUtils.getTempDirectory());
FileUtils.deleteQuietly(tempDir);
FileUtils.forceMkdir(tempDir);
代码示例来源:origin: apache/incubator-pinot
workingDir = FileUtils.getTempDirectory();
} else {
workingDir = new File(_workingDirectory);
代码示例来源:origin: apache/incubator-pinot
_tempDir = builderConfig.getOutDir();
if (_tempDir == null) {
_tempDir = new File(FileUtils.getTempDirectory(), V1Constants.STAR_TREE_INDEX_DIR + "_" + DateTime.now());
代码示例来源:origin: gocd/gocd
@Test
public void shouldRefreshUsableSpaceOfAgent() throws Exception {
AgentIdentifier identifier = new AgentIdentifier("local.in", "127.0.0.1", "uuid-1");
String workingDirectory = FileUtils.getTempDirectory().getAbsolutePath();
AgentRuntimeInfo runtimeInfo = ElasticAgentRuntimeInfo.fromAgent(identifier, AgentRuntimeStatus.Idle, workingDirectory, false);
long space = ElasticAgentRuntimeInfo.usableSpace(workingDirectory);
assertThat(runtimeInfo.getUsableSpace(), is(space));
}
}
代码示例来源:origin: naver/ngrinder
@SuppressWarnings("ResultOfMethodCallIgnored")
private StringBuilder addPythonPathJvmArgument(StringBuilder jvmArguments) {
jvmArguments.append(" -Dpython.path=");
jvmArguments.append(new File(baseDirectory.getFile(), "lib").getAbsolutePath());
String pythonPath = System.getenv().get("PYTHONPATH");
if (pythonPath != null) {
jvmArguments.append(File.pathSeparator).append(pythonPath);
}
String pythonHome = System.getenv().get("PYTHONHOME");
if (pythonHome != null) {
jvmArguments.append(" -Dpython.home=");
jvmArguments.append(pythonHome);
}
jvmArguments.append(" ");
File jythonCache = new File(FileUtils.getTempDirectory(), "jython");
jythonCache.mkdirs();
jvmArguments.append(" -Dpython.cachedir=").append(jythonCache.getAbsolutePath()).append(" ");
return jvmArguments;
}
代码示例来源:origin: borball/weixin-sdk
File tempFile = new File(FileUtils.getTempDirectory(), fileName);
FileUtils.copyInputStreamToFile(inputStream, tempFile);
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException, InterruptedException {
Configuration conf = HBaseConfiguration.create();
Connection connection = ConnectionFactory.createConnection(conf);
// vv TokenExample
Token<AuthenticationTokenIdentifier> token =
TokenUtil.obtainToken(connection);
String urlString = token.encodeToUrlString();
File temp = new File(FileUtils.getTempDirectory(), "token");
FileUtils.writeStringToFile(temp, urlString);
System.out.println("Encoded Token: " + urlString);
String strToken = FileUtils.readFileToString(new File("token"));
Token token2 = new Token();
token2.decodeFromUrlString(strToken);
UserGroupInformation.getCurrentUser().addToken(token2);
// ^^ TokenExample
connection.close();
}
}
代码示例来源:origin: borball/weixin-sdk
public String post(String url, InputStream inputStream, String fileName, Map<String, String> form) {
File tempFile = new File(FileUtils.getTempDirectory(), fileName);
try {
FileUtils.copyInputStreamToFile(inputStream, tempFile);
} catch (IOException e) {
logger.error("http post: {} failed", url, e);
throw new WxRuntimeException(999, "Copy stream to file failed:" + e.getMessage());
}
try {
return httpPost(appendAccessToken(url), tempFile, form);
} catch (Exception e) {
if(e instanceof WxRuntimeException) {
WxRuntimeException wxRuntimeException = (WxRuntimeException) e;
if(invalidToken(wxRuntimeException.getCode())) {
logger.warn("token invalid: {}, will refresh.", wxRuntimeException.getCode());
refreshToken();
return httpPost(appendAccessToken(url), tempFile, form);
}
}
throw e;
} finally {
FileUtils.deleteQuietly(tempFile);
}
}
代码示例来源:origin: yjjdick/sdb-mall
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
代码示例来源:origin: com.quhaodian.discover/discover-plug
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
代码示例来源:origin: com.haoxuer.discover/discover-common-plug
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
代码示例来源:origin: com.gitee.qdbp.thirdparty/ueditor
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
代码示例来源:origin: com.googlecode.jeeunit/jeeunit-jboss7
private File createTempDir() {
File tmpRoot = FileUtils.getTempDirectory();
File tmpDir = new File(tmpRoot, UUID.randomUUID().toString());
tmpDir.mkdir();
return tmpDir;
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-deskmanager
public static File createTmpFolder() throws IOException {
File root = org.apache.commons.io.FileUtils.getTempDirectory();
File tmpFolder;
do {
tmpFolder = new File(root, UUID.randomUUID().toString());
} while (tmpFolder.isDirectory());
tmpFolder.mkdir();
return tmpFolder;
}
代码示例来源:origin: com.adobe.testing/s3mock
private File createRootFolder(final String rootDirectory) {
final File root;
if (rootDirectory == null || rootDirectory.isEmpty()) {
root = new File(FileUtils.getTempDirectory(), "s3mockFileStore" + new Date().getTime());
} else {
root = new File(rootDirectory);
}
root.deleteOnExit();
root.mkdir();
return root;
}
代码示例来源:origin: cloudant/sync-android
@Before
public void setUp() {
TEST_PATH = new File(FileUtils.getTempDirectory().getAbsolutePath(),
"DatastoreManagerTest" + UUID.randomUUID());
}
内容来源于网络,如有侵权,请联系作者删除!