List of usage examples for java.io File mkdirs
public boolean mkdirs()
From source file:com.trackplus.ddl.DataReaderTest.java
public static void main(String[] args) { DatabaseInfo databaseInfo = createFirebirdDbInfo(); Logger LOGGER = LogManager.getLogger(DataReader.class); LoggingConfigBL.setLevel(LOGGER, Level.DEBUG); String dbaseDir = "d:\\svn2015\\core\\com.trackplus.core\\src\\main\\webapp\\dbase"; String tmpDir = "d:\\tmp7\\7"; File file = new File(tmpDir); if (!file.exists()) { file.mkdirs(); }//from w w w . j a v a2 s . c o m exportSchema(new File(tmpDir), dbaseDir); try { DataReader.writeDataToSql(databaseInfo, tmpDir); } catch (DDLException e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step4BoilerPlateRemoval.java
public static void main(String[] args) throws IOException { // input dir - list of xml query containers // step3-filled-raw-html File inputDir = new File(args[0]); // output dir File outputDir = new File(args[1]); if (!outputDir.exists()) { outputDir.mkdirs(); }/* www . j a v a2s . c o m*/ // keep original html? (true == default) boolean keepOriginalHTML = !(args.length > 2 && "false".equals(args[2])); System.out.println(keepOriginalHTML); BoilerPlateRemoval boilerPlateRemoval = new JusTextBoilerplateRemoval(); // iterate over query containers for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); for (QueryResultContainer.SingleRankedResult rankedResults : queryResultContainer.rankedResults) { // boilerplate removal // there are some empty (corrupted) documents in ClueWeb, namely 0308wb-83.warc.gz if (rankedResults.originalHtml != null) { rankedResults.plainText = boilerPlateRemoval.getMinimalHtml(rankedResults.originalHtml, null); } if (!keepOriginalHTML) { rankedResults.originalHtml = null; } } // and save the query to output dir File outputFile = new File(outputDir, queryResultContainer.qID + ".xml"); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } }
From source file:edu.usf.cutr.gtfsrtvalidator.Main.java
public static void main(String[] args) throws InterruptedException, ParseException { // Parse command line parameters int port = getPortFromArgs(args); HibernateUtil.configureSessionFactory(); GTFSDB.initializeDB();/*from ww w. j a va 2 s. c o m*/ Server server = new Server(port); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); /* * Create '/classes/webroot' directory if not exists in the same directory where jar is located. * '/jar-location-directory/classes/webroot' is where we store static GTFS feed validation json output. * 'classes/webroot' is created so that it will be in sync with or without build directories. */ File jsonDirectory = new File(jsonFilePath); jsonDirectory.mkdirs(); /* * As we cannot directly add static GTFS feed json output file to jar, we add an other web resource directory 'jsonFilePath' * such that json output file can also be accessed from server. * Now there are two paths for web resources; 'BASE_RESOURCE' and 'jsonFilePath'. * 'jsonFilePath' as web resource directory is needed when we don't have any build folders. For example, see issue #181 * where we only have Travis generated jar file without any build directories. */ ResourceCollection resources = new ResourceCollection(new String[] { BASE_RESOURCE, jsonFilePath, }); context.setBaseResource(resources); server.setHandler(context); context.addServlet(GetFeedJSON.class, "/getFeed"); context.addServlet(DefaultServlet.class, "/"); ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/api/*"); jerseyServlet.setInitOrder(1); jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", "org.glassfish.jersey.moxy.json.MoxyJsonFeature"); jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "edu.usf.cutr.gtfsrtvalidator.api.resource"); try { server.start(); _log.info("Go to http://localhost:" + port + " in your browser"); server.join(); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.gov.lexml.swing.spellchecker.SpellcheckerMain.java
public static void main(String[] args) { try {/* w w w .j a v a 2 s .c om*/ System.out.println("Preparando diretrio"); File baseDir = new File("target/spellchecker"); if (!baseDir.isDirectory()) { baseDir.mkdirs(); } Spellchecker s = SpellcheckerFactory.getInstance().createSpellchecker(baseDir); System.out.println("Hunspell library and dictionary loaded"); String words[] = { "subnutido", "isso", "nao" }; for (int i = 0; i < words.length; i++) { String word = words[i]; if (s.misspelled(word)) { List<String> suggestions = s.suggest(word); print("misspelled: " + word); if (suggestions.isEmpty()) { print("\tNo suggestions."); } else { print("\tTry:"); for (String sug : suggestions) { print(" " + sug); } } println(""); } else { println("ok: " + word); } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:cz.pichlik.goodsentiment.MockDataGenerator.java
public static void main(String args[]) throws IOException { String outputDirectory = args[0]; LocalDate seedDate = LocalDate.of(2015, 9, 1); for (int i = 0; i < 100; i++) { LocalDate date = seedDate.plusDays(i); File outputDirectoryFile = new File(outputDirectory); outputDirectoryFile.mkdirs(); File outputFile = new File(outputDirectoryFile, String.format("goodsentinment-data-%s.csv", date)); generateFile(outputFile, date);//from w ww. jav a 2 s. com } }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step2FillWithRetrievedResults.java
public static void main(String[] args) throws IOException { // input dir - list of xml query containers File inputDir = new File(args[0]); // retrieved results from Technion // ltr-50queries-100docs.txt File ltr = new File(args[1]); // output dir File outputDir = new File(args[2]); if (!outputDir.exists()) { outputDir.mkdirs(); }//w w w. j ava 2 s . c om // load the query containers first (into map: id + container) Map<String, QueryResultContainer> queryResults = new HashMap<>(); for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { System.out.println(f); QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); queryResults.put(queryResultContainer.qID, queryResultContainer); } // iterate over IR results for (String line : FileUtils.readLines(ltr)) { String[] split = line.split("\\s+"); Integer origQueryId = Integer.valueOf(split[0]); String clueWebID = split[2]; Integer rank = Integer.valueOf(split[3]); double score = Double.valueOf(split[4]); String additionalInfo = split[5]; // get the container for this result QueryResultContainer container = queryResults.get(origQueryId.toString()); if (container != null) { // add new result QueryResultContainer.SingleRankedResult result = new QueryResultContainer.SingleRankedResult(); result.clueWebID = clueWebID; result.rank = rank; result.score = score; result.additionalInfo = additionalInfo; if (container.rankedResults == null) { container.rankedResults = new ArrayList<>(); } container.rankedResults.add(result); } } // save all containers to the output dir for (QueryResultContainer queryResultContainer : queryResults.values()) { File outputFile = new File(outputDir, queryResultContainer.qID + ".xml"); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } }
From source file:net.minecraftforge.fml.common.patcher.GenDiffSet.java
public static void main(String[] args) throws IOException { String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft String deobfData = args[2]; //Path to FML's deobfusication_data.lzma String outputDir = args[3]; //Path to place generated .binpatch String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir)); Delta delta = new Delta(); FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE; remapper.setupLoadOnly(deobfData, false); JarFile sourceZip = new JarFile(sourceJar); boolean kill = killTarget.equalsIgnoreCase("true"); File f = new File(outputDir); f.mkdirs(); for (String name : remapper.getObfedClasses()) { // Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name)); String fileName = name;/* w ww . ja v a 2 s .c o m*/ String jarName = name; if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH))) { fileName = "_" + name; } File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class"); jarName = jarName + ".class"; if (targetFile.exists()) { String sourceClassName = name.replace('/', '.'); String targetClassName = remapper.map(name).replace('/', '.'); JarEntry entry = sourceZip.getJarEntry(jarName); byte[] vanillaBytes = toByteArray(sourceZip, entry); byte[] patchedBytes = Files.toByteArray(targetFile); byte[] diff = delta.compute(vanillaBytes, patchedBytes); ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50); // Original name diffOut.writeUTF(name); // Source name diffOut.writeUTF(sourceClassName); // Target name diffOut.writeUTF(targetClassName); // exists at original diffOut.writeBoolean(entry != null); if (entry != null) { diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt()); } // length of patch diffOut.writeInt(diff.length); // patch diffOut.write(diff); File target = new File(outputDir, targetClassName + ".binpatch"); target.getParentFile().mkdirs(); Files.write(diffOut.toByteArray(), target); Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s", name, targetClassName, target.getAbsolutePath())); if (kill) { targetFile.delete(); Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString())); } } } sourceZip.close(); }
From source file:com.googlecode.hiberpcml.generator.Tool.java
public static void main(String arg[]) throws Exception { CommandLineParser parser = new PosixParser(); Options options = new Options(); Option destinyOpt = new Option("t", "target", true, "target of the generated classes"); destinyOpt.setArgName("target"); options.addOption(destinyOpt);//from ww w . j a v a 2 s .c om Option packageOpt = new Option("p", "package", true, "Java Package of the generated classes"); packageOpt.setArgName("package"); options.addOption(packageOpt); Option webServiceOpt = new Option("w", "webservice", true, "build webservice classes"); webServiceOpt.setArgs(2); webServiceOpt.setArgName("serviceName service"); options.addOption(webServiceOpt); options.addOption(webServiceOpt); CommandLine cmd = parser.parse(options, arg); if (cmd.getArgs().length == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("generator [options] FILE|DIRECTORY.", options); System.exit(1); } Pcml pcml; ArrayList<File> filesToParse = getFilesToParse(cmd.getArgs()[0]); JCodeModel cm = new JCodeModel(); JPackage _package = cm._package(cmd.getOptionValue("p", "")); Generator generator; WSGenerator wsGenerator = null; File targetFile = new File(cmd.getOptionValue("t", "./target")); targetFile.mkdirs(); if (cmd.hasOption("w")) { wsGenerator = new WSGenerator(_package, cmd.getOptionValues("w")[0], cmd.getOptionValues("w")[1]); } for (File file : filesToParse) { pcml = Util.load(file); if (cmd.hasOption("w")) { wsGenerator.addMethod(pcml); } else { generator = new Generator(); generator.generate(_package, pcml); } } cm.build(targetFile); }
From source file:bpgead2pdf.java
/** * Main method./*from w w w . jav a2 s . c o m*/ * @param args command-line arguments */ public static void main(String[] args) { try { System.out.println("Preparing..."); // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); // Setup input and output files File xmlfile = new File(args[0]); String xsltfile = new String("http://www.library.yale.edu/facc/xsl/fo/yul.ead2002.pdf.xsl"); String pdffn = new String(FilenameUtils.getBaseName(args[0]) + ".pdf"); File pdffile = new File(outDir, pdffn); System.out.println("Input: XML (" + xmlfile + ")"); System.out.println("Stylesheet: " + xsltfile); System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired // configure XSLT Processor Processor processor = new Processor(false); // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); try { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); // Setup XSLT XsltCompiler compiler = processor.newXsltCompiler(); XsltExecutable transform = compiler.compile(new StreamSource(xsltfile)); XsltTransformer transformer = transform.load(); // Set the value of a <param> in the stylesheet // transformer.setParameter("versionParam", "2.0"); // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); // Resulting SAX events (the generated FO) must be piped through to FOP SAXDestination res = new SAXDestination(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.setDestination(res); transformer.setSource(src); transformer.transform(); } finally { out.close(); } System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } }
From source file:org.alex73.osm.validators.vioski.Export.java
public static void main(String[] args) throws Exception { RehijonyLoad.load(Env.readProperty("dav") + "/Rehijony.xml"); osm = new Belarus(); String dav = Env.readProperty("dav") + "/Nazvy_nasielenych_punktau.csv"; List<Miesta> daviednik = new CSV('\t').readCSV(dav, Miesta.class); Map<String, List<Mdav>> rajony = new TreeMap<>(); for (Miesta m : daviednik) { String r = m.rajon.startsWith("<") ? m.rajon : m.rajon + " "; List<Mdav> list = rajony.get(r); if (list == null) { list = new ArrayList<>(); rajony.put(r, list);//from www. j a v a 2 s. co m } Mdav mm = new Mdav(); mm.osmID = m.osmID; mm.ss = m.sielsaviet; mm.why = m.osmComment; mm.nameBe = m.nazvaNoStress; mm.nameRu = m.ras; mm.varyjantBe = m.varyjantyBel; mm.varyjantRu = m.rasUsedAsOld; list.add(mm); } placeTag = osm.getTagsPack().getTagCode("place"); osm.byTag("place", o -> o.isNode() && !o.getTag(placeTag).equals("island") && !o.getTag(placeTag).equals("islet"), o -> processNode((IOsmNode) o)); String outDir = Env.readProperty("out.dir"); File foutDir = new File(outDir + "/vioski"); foutDir.mkdirs(); Map<String, String> padzielo = new TreeMap<>(); for (Voblasc v : RehijonyLoad.kraina.getVoblasc()) { for (Rajon r : v.getRajon()) { padzielo.put(r.getNameBe(), osm.getObject(r.getOsmID()).getTag("name", osm)); } } ObjectMapper om = new ObjectMapper(); String o = "var data={};\n"; o += "data.dav=" + om.writeValueAsString(rajony) + "\n"; o += "data.map=" + om.writeValueAsString(map) + "\n"; o += "data.padziel=" + om.writeValueAsString(padzielo) + "\n"; FileUtils.writeStringToFile(new File(outDir + "/vioski/data.js"), o); FileUtils.copyFileToDirectory(new File("vioski/control.js"), foutDir); FileUtils.copyFileToDirectory(new File("vioski/vioski.html"), foutDir); }