Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Creating new directories
  2. private static File createNewTempDir() {
  3. File baseDir = new File(System.getProperty("java.io.tmpdir"));
  4. String baseNamePrefix = System.currentTimeMillis() + "_" + Math.random() + "-";
  5. LOG.info(System.getProperty("java.io.tmpdir"));
  6. File tempDir = new File(baseDir, baseNamePrefix + "0");
  7. LOG.info(tempDir.getAbsolutePath());
  8.  
  9. tempDir.mkdirs();
  10.  
  11. if (tempDir.exists()) {
  12.   LOG.info("I would be happy!");
  13. }
  14. else {
  15.   LOG.info("No folder there");
  16. }
  17. return tempDir;
  18. }
  19.        
  20. if (tempDir.exists()) {
  21.   LOG.info("I would be happy!");
  22. }
  23. else {
  24.   LOG.info("No folder there");
  25. }
  26.        
  27. public static void main() {
  28.         File baseDir = new File(System.getProperty("java.io.tmpdir"));
  29.         File tempDir = new File(baseDir, "test0");
  30.         System.err.println(tempDir.getAbsolutePath());
  31.  
  32.         tempDir.mkdir();
  33.  
  34.         System.err.println("is it a dir? " + tempDir.isDirectory());
  35.         System.err.println("does it exist? " + tempDir.exists());
  36.     }