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; }
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; }
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; }
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; }
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; }
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; }
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; }
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
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(); } }
@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); }