本文整理了Java中org.apache.cxf.helpers.FileUtils.getDefaultTempDir()
方法的一些代码示例,展示了FileUtils.getDefaultTempDir()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getDefaultTempDir()
方法的具体详情如下:
包路径:org.apache.cxf.helpers.FileUtils
类名称:FileUtils
方法名:getDefaultTempDir
暂无
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
public static File createTempFile(String prefix, String suffix, File parentDir,
boolean deleteOnExit) throws IOException {
File result = null;
File parent = (parentDir == null)
? getDefaultTempDir()
: parentDir;
if (suffix == null) {
suffix = ".tmp";
}
if (prefix == null) {
prefix = "cxf";
} else if (prefix.length() < 3) {
prefix = prefix + "cxf";
}
result = File.createTempFile(prefix, suffix, parent);
//if parentDir is null, we're in our default dir
//which will get completely wiped on exit from our exit
//hook. No need to set deleteOnExit() which leaks memory.
if (deleteOnExit && parentDir != null) {
result.deleteOnExit();
}
return result;
}
代码示例来源:origin: org.apache.cxf/cxf-common-utilities
public static File createTempFile(String prefix, String suffix, File parentDir,
boolean deleteOnExit) throws IOException {
File result = null;
File parent = (parentDir == null)
? getDefaultTempDir()
: parentDir;
if (suffix == null) {
suffix = ".tmp";
}
if (prefix == null) {
prefix = "cxf";
} else if (prefix.length() < 3) {
prefix = prefix + "cxf";
}
result = File.createTempFile(prefix, suffix, parent);
//if parentDir is null, we're in our default dir
//which will get completely wiped on exit from our exit
//hook. No need to set deleteOnExit() which leaks memory.
if (deleteOnExit && parentDir != null) {
result.deleteOnExit();
}
return result;
}
代码示例来源:origin: org.apache.cxf/cxf-api
public static File createTempFile(String prefix, String suffix, File parentDir,
boolean deleteOnExit) throws IOException {
File result = null;
File parent = (parentDir == null)
? getDefaultTempDir()
: parentDir;
if (suffix == null) {
suffix = ".tmp";
}
if (prefix == null) {
prefix = "cxf";
} else if (prefix.length() < 3) {
prefix = prefix + "cxf";
}
result = File.createTempFile(prefix, suffix, parent);
//if parentDir is null, we're in our default dir
//which will get completely wiped on exit from our exit
//hook. No need to set deleteOnExit() which leaks memory.
if (deleteOnExit && parentDir != null) {
result.deleteOnExit();
}
return result;
}
代码示例来源:origin: apache/cxf
public static File createTempFile(String prefix, String suffix, File parentDir,
boolean deleteOnExit) throws IOException {
File result = null;
File parent = (parentDir == null)
? getDefaultTempDir()
: parentDir;
if (suffix == null) {
suffix = ".tmp";
}
if (prefix == null) {
prefix = "cxf";
} else if (prefix.length() < 3) {
prefix = prefix + "cxf";
}
result = Files.createTempFile(parent.toPath(), prefix, suffix).toFile();
//if parentDir is null, we're in our default dir
//which will get completely wiped on exit from our exit
//hook. No need to set deleteOnExit() which leaks memory.
if (deleteOnExit && parentDir != null) {
result.deleteOnExit();
}
return result;
}
代码示例来源:origin: org.apache.cxf/cxf-core
public static File createTempFile(String prefix, String suffix, File parentDir,
boolean deleteOnExit) throws IOException {
File result = null;
File parent = (parentDir == null)
? getDefaultTempDir()
: parentDir;
if (suffix == null) {
suffix = ".tmp";
}
if (prefix == null) {
prefix = "cxf";
} else if (prefix.length() < 3) {
prefix = prefix + "cxf";
}
result = Files.createTempFile(parent.toPath(), prefix, suffix).toFile();
//if parentDir is null, we're in our default dir
//which will get completely wiped on exit from our exit
//hook. No need to set deleteOnExit() which leaks memory.
if (deleteOnExit && parentDir != null) {
result.deleteOnExit();
}
return result;
}
代码示例来源:origin: apache/cxf
public static boolean isValidFileName(String name) {
for (int i = name.length(); i > 0; i--) {
char c = name.charAt(i - 1);
for (char c2 : ILLEGAL_CHARACTERS) {
if (c == c2) {
return false;
}
}
}
File file = new File(getDefaultTempDir(), name);
boolean isValid = true;
try {
if (file.exists()) {
return true;
}
if (file.createNewFile()) {
file.delete();
}
} catch (IOException e) {
isValid = false;
}
return isValid;
}
代码示例来源:origin: org.apache.cxf/cxf-core
public static boolean isValidFileName(String name) {
for (int i = name.length(); i > 0; i--) {
char c = name.charAt(i - 1);
for (char c2 : ILLEGAL_CHARACTERS) {
if (c == c2) {
return false;
}
}
}
File file = new File(getDefaultTempDir(), name);
boolean isValid = true;
try {
if (file.exists()) {
return true;
}
if (file.createNewFile()) {
file.delete();
}
} catch (IOException e) {
isValid = false;
}
return isValid;
}
代码示例来源:origin: apache/cxf
int countTempFiles() {
File file = FileUtils.getDefaultTempDir();
File[] files = file.listFiles();
if (files == null) {
return 0;
}
int count = 0;
for (File f : files) {
if (f.isFile()) {
count++;
}
}
return count;
}
@Test
代码示例来源:origin: apache/cxf
public static void updatePolicyRef(String file, String oldData,
String newData) throws IOException {
File f = FileUtils.getDefaultTempDir();
InputStream in = PolicyTestHelper.class.getResourceAsStream(file);
String s = IOUtils.readStringFromStream(in);
s = s.replaceAll(oldData, newData);
File newFile = new File(f, file);
FileWriter fw = new FileWriter(newFile);
fw.write(s);
fw.close();
}
}
代码示例来源:origin: apache/cxf
@Test
public void testBigList() throws Exception {
int size = 1000;
List<String> l = new ArrayList<>(size);
for (int x = 0; x < size; x++) {
l.add("Need to create a pretty big soap message to make sure we go over "
+ "some of the default buffer sizes and such so we can see what really"
+ "happens when we do that - " + x);
}
setupForTest(false);
List<String> item = client.echoBigList(l);
Assert.assertEquals(size, item.size());
//CXF-2768
File f = FileUtils.getDefaultTempDir();
Assert.assertEquals(0, f.listFiles().length);
}
内容来源于网络,如有侵权,请联系作者删除!