List of usage examples for java.io File mkdir
public boolean mkdir()
From source file:fedora.test.api.TestHTTPStatusCodesConfigC.java
private static void addSystemWidePolicyFile(String filename, String xml) throws Exception { final String policyDir = "data/fedora-xacml-policies/repository-policies/junit"; File dir = new File(FEDORA_HOME, policyDir); dir.mkdir(); File policyFile = new File(dir, filename); writeStringToFile(xml, policyFile);//ww w . ja v a 2 s . co m // for new policy store... addPolicy(xml); }
From source file:net.naijatek.myalumni.util.utilities.FileUtil.java
public static void createDir(final String dir, final boolean ignoreIfExitst) throws IOException { File file = new File(dir); if (ignoreIfExitst && file.exists()) { return;// w ww . j av a 2s . c o m } if (file.mkdir() == false) { throw new IOException("Cannot create the directory = " + dir); } }
From source file:edu.iu.daal_naive.NaiveUtil.java
static void generatePoints(int numOfDataPoints, int vectorSize, int numPointFiles, int nClasses, String localInputDir, FileSystem fs, Path dataDir) throws IOException, InterruptedException, ExecutionException { int pointsPerFile = numOfDataPoints / numPointFiles; System.out.println("Writing " + pointsPerFile + " vectors to a file"); // Check data directory if (fs.exists(dataDir)) { fs.delete(dataDir, true);/* ww w.ja v a 2 s. c o m*/ } // Check local directory File localDir = new File(localInputDir); // If existed, regenerate data if (localDir.exists() && localDir.isDirectory()) { for (File file : localDir.listFiles()) { file.delete(); } localDir.delete(); } boolean success = localDir.mkdir(); if (success) { System.out.println("Directory: " + localInputDir + " created"); } if (pointsPerFile == 0) { throw new IOException("No point to write."); } // Create random data points int poolSize = Runtime.getRuntime().availableProcessors(); ExecutorService service = Executors.newFixedThreadPool(poolSize); List<Future<?>> futures = new LinkedList<Future<?>>(); for (int k = 0; k < numPointFiles; k++) { Future<?> f = service.submit( new DataGenNaiveBayes(localInputDir, Integer.toString(k), pointsPerFile, vectorSize, nClasses)); futures.add(f); // add a new thread } for (Future<?> f : futures) { f.get(); } // Shut down the executor service so that this // thread can exit service.shutdownNow(); // Wrap to path object Path localInput = new Path(localInputDir); fs.copyFromLocalFile(localInput, dataDir); }
From source file:ee.ria.xroad.asyncdb.AsyncDBIntegrationTest.java
private static void setUpCorruptDb() throws Exception { File corruptDbDir = new File(CORRUPT_DB_DIR); corruptDbDir.mkdir(); FileUtils.copyDirectory(new File("src/test/resources/db_corrupt"), corruptDbDir); System.setProperty(SystemProperties.ASYNC_DB_PATH, CORRUPT_DB_DIR); ClientId provider = ClientId.create("EE", "GOV", "XTS4CLIENT"); queue = AsyncDB.getMessageQueue(provider); }
From source file:expansionBlocks.ProcessCommunities.java
private static void printTopologicalExtension(Query query, Map<Entity, Double> community) throws FileNotFoundException, UnsupportedEncodingException { File theDir = new File("images"); if (!theDir.exists()) { boolean result = theDir.mkdir(); }/* ww w .ja v a2 s.c o m*/ PrintWriter writer = FileManagement.Writer .getWriter("images/" + query.getId() + "TopologicalCommunity.txt"); writer.println("strict digraph G{"); Set<Entity> entitySet = community.keySet(); Set<Long> categoriesSet = new HashSet<>(); for (Entity e : entitySet) { categoriesSet.addAll(Article.getCategories(e.getId())); } Map<Long, Double> categoryWeightMap = new HashMap<>(); Double maxW = 0.0; for (Entity entity : entitySet) { Long entityID = entity.getId(); maxW = maxW < community.get(entityID) ? community.get(entityID) : maxW; Set<Long> neighbors = Article.getNeighbors(entityID, Graph.EDGES_OUT); Collection<Long> intersection = CollectionUtils.intersection(neighbors, entitySet); for (Long neighbourID : intersection) { if (!Article.isARedirect(entityID) && !Article.isARedirect(neighbourID)) { writer.println(entityID + " -> " + neighbourID + " [color=red];"); } } Set<Long> categories = Article.getCategories(entityID); for (Long categoryID : categories) { writer.println(entityID + " -> " + categoryID + " [color=green];"); Double w = categoryWeightMap.put(categoryID, community.get(entityID)); if (w != null && w > community.get(entityID)) categoryWeightMap.put(categoryID, w); } Set<Long> redirects = Article.getRedirections(entityID); /* for (Long redirectID : redirects) { if (!Article.isARedirect(articleID)) { } }*/ } for (Long categoryID : categoriesSet) { Set<Long> neighbors = Category.getNeigbors(categoryID, Graph.EDGES_OUT); Collection<Long> intersection = CollectionUtils.intersection(neighbors, categoriesSet); for (Long neighbourID : intersection) { writer.println(categoryID + " -> " + neighbourID + " [color=blue];"); } neighbors = Category.getNeigbors(categoryID, Graph.EDGES_IN); intersection = CollectionUtils.intersection(neighbors, categoriesSet); for (Long neighbourID : intersection) { writer.println(neighbourID + " -> " + categoryID + " [color=blue];"); } } for (Entity entity : entitySet) { String title = entity.getName(); title = Normalizer.normalize(title, Normalizer.NFD); title = title.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); title = title.replaceAll("[.]+", " "); //writer.println(id + "[label=\"" + title + "\"];"); // String weight = new BigDecimal(community.get(id)*10).toPlainString(); BigDecimal weightDouble = new BigDecimal(2 / maxW * community.get(entity) + .5); String weight = weightDouble.toPlainString(); writer.println(entity + "[label=\"" + title + "\", width=" + weight + ", height=" + weight + " fixedsize=true,style=filled,color=\"#c0c0c0\"];"); } for (Long id : categoriesSet) { String title = (new Category(id)).getName(); title = Normalizer.normalize(title, Normalizer.NFD); title = title.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); title = title.replaceAll("[.]+", " "); BigDecimal weightDouble = new BigDecimal(2 / maxW * categoryWeightMap.get(id) + .5); String weight = weightDouble.toPlainString(); writer.println(id + "[label=\"" + title + "\", width=" + weight + ", height=" + weight + " fixedsize=true,style=filled,color=\"#f0f0f0\"];"); } writer.println("}"); writer.close(); }
From source file:edu.iu.daal_naive.NaiveUtil.java
static void generateGroundTruth(int numOfDataPoints, int nClasses, String localInputDir, FileSystem fs, Path dataDir) throws IOException, InterruptedException, ExecutionException { // Check data directory if (fs.exists(dataDir)) { fs.delete(dataDir, true);// w ww . j ava 2 s . com } // Check local directory File localDir = new File(localInputDir); // If existed, regenerate data if (localDir.exists() && localDir.isDirectory()) { for (File file : localDir.listFiles()) { file.delete(); } localDir.delete(); } boolean success = localDir.mkdir(); if (success) { System.out.println("Directory: " + localInputDir + " created"); } // generate test points BufferedWriter writer = new BufferedWriter(new FileWriter(localInputDir + File.separator + "groundtruth")); Random random = new Random(); // double point = 0; int label = 0; for (int i = 0; i < numOfDataPoints; i++) { // for (int j = 0; j < vectorSize; j++) { // point = random.nextDouble()*2 -1; // writer.write(String.valueOf(point)); // writer.write(","); // } label = random.nextInt(nClasses); writer.write(String.valueOf(label)); writer.newLine(); } writer.close(); System.out.println("Write groundtruth data file"); // Wrap to path object Path localInput = new Path(localInputDir); fs.copyFromLocalFile(localInput, dataDir); }
From source file:edu.iu.daal_naive.NaiveUtil.java
static void generateTestPoints(int numOfDataPoints, int vectorSize, int nClasses, String localInputDir, FileSystem fs, Path dataDir) throws IOException, InterruptedException, ExecutionException { // Check data directory if (fs.exists(dataDir)) { fs.delete(dataDir, true);// ww w .j a v a 2 s. co m } // Check local directory File localDir = new File(localInputDir); // If existed, regenerate data if (localDir.exists() && localDir.isDirectory()) { for (File file : localDir.listFiles()) { file.delete(); } localDir.delete(); } boolean success = localDir.mkdir(); if (success) { System.out.println("Directory: " + localInputDir + " created"); } // generate test points BufferedWriter writer = new BufferedWriter(new FileWriter(localInputDir + File.separator + "testdata")); Random random = new Random(); double point = 0; int label = 0; for (int i = 0; i < numOfDataPoints; i++) { for (int j = 0; j < vectorSize; j++) { point = random.nextDouble() * 2 - 1; writer.write(String.valueOf(point)); writer.write(","); } label = random.nextInt(nClasses); writer.write(String.valueOf(label)); writer.newLine(); } writer.close(); System.out.println("Write test data file"); // Wrap to path object Path localInput = new Path(localInputDir); fs.copyFromLocalFile(localInput, dataDir); }
From source file:com.cenrise.test.azkaban.Utils.java
public static File createTempDir(final File parent) { final File temp = new File(parent, Integer.toString(Math.abs(RANDOM.nextInt()) % 100000000)); temp.delete();// w w w. j ava 2s.com temp.mkdir(); temp.deleteOnExit(); return temp; }
From source file:de.schaeuffelhut.android.openvpn.Preferences.java
public final static File getConfigDir(Context context, SharedPreferences sharedPreferences) { final File configDir; if (getUseInternalStorage(sharedPreferences)) { configDir = new File(context.getFilesDir(), "config.d"); if (!configDir.exists()) configDir.mkdir(); } else {/*from w w w . ja v a2 s. c o m*/ configDir = getExternalStorageAsFile(sharedPreferences); } return configDir; }