List of usage examples for java.io File isDirectory
public boolean isDirectory()
From source file:br.gov.lexml.swing.spellchecker.SpellcheckerMain.java
public static void main(String[] args) { try {/*from w w w . j ava 2 s . com*/ 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:com.appeligo.ccdataindexer.SpellIndexer.java
public static void main(String args[]) throws Exception { ConfigurationService.setRootDir(new File("config")); ConfigurationService.setEnvName("live"); ConfigurationService.init();//from w w w . ja v a 2 s . co m if (args.length < 2 || args.length > 3) { usage(); System.exit(-1); } File file = new File(args[0]); if (!file.isDirectory()) { usage(); System.exit(-1); } long now = System.currentTimeMillis(); try { DidYouMeanIndexer.createDefaultSpellIndex(args[0], args[1]); } catch (IOException e) { log.error("Can't create spell index", e); } long after = System.currentTimeMillis(); log.info("Processing took " + ((after - now) / (60 * 1000)) + " minutes to index the programs."); //log.info("Indexed " + count+ " programs"); }
From source file:Main.java
public static void main(String[] args) { String dirPath = "C:\\"; File dir = new File(dirPath); // Create a file filter to exclude any .SYS file FileFilter filter = file -> { if (file.isFile()) { String fileName = file.getName().toLowerCase(); if (fileName.endsWith(".sys")) { return false; }//from www . j av a2s . c o m } return true; }; File[] list = dir.listFiles(filter); for (File f : list) { if (f.isFile()) { System.out.println(f.getPath() + " (File)"); } else if (f.isDirectory()) { System.out.println(f.getPath() + " (Directory)"); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { ZipInputStream zipinputstream = new ZipInputStream(new FileInputStream("filename")); ZipEntry zipentry = zipinputstream.getNextEntry(); while (zipentry != null) { String entryName = zipentry.getName(); File newFile = new File(entryName); String directory = newFile.getParent(); if (directory == null) { if (newFile.isDirectory()) break; }/*from w w w . ja va 2 s . com*/ RandomAccessFile rf = new RandomAccessFile(entryName, "r"); String line; if ((line = rf.readLine()) != null) { System.out.println(line); } rf.close(); zipinputstream.closeEntry(); zipentry = zipinputstream.getNextEntry(); } zipinputstream.close(); }
From source file:fr.ericlab.mabed.app.Main.java
public static void main(String[] args) throws IOException { Locale.setDefault(Locale.US); Configuration configuration = new Configuration(); Corpus corpus = new Corpus(configuration); System.out.println("MABED: Mention-Anomaly-Based Event Detection"); if (args.length == 0 || args[0].equals("-help")) { System.out.println("For more information on how to run MABED, see the README.txt file"); } else {/*from w w w . j a v a2 s . c o m*/ if (args[0].equals("-run")) { try { if (configuration.numberOfThreads > 1) { System.out.println("Running the parallelized implementation with " + configuration.numberOfThreads + " threads (this computer has " + Runtime.getRuntime().availableProcessors() + " available threads)"); } else { System.out.println("Running the centralized implementation"); } corpus.loadCorpus(configuration.numberOfThreads > 1); String output = "MABED: Mention-Anomaly-Based Event Detection\n" + corpus.output + "\n"; System.out.println("-------------------------\n" + Util.getDate() + " MABED is running\n-------------------------"); output += "-------------------------\n" + Util.getDate() + " MABED is running\n-------------------------\n"; System.out.println(Util.getDate() + " Reading parameters:\n - k = " + configuration.k + ", p = " + configuration.p + ", theta = " + configuration.theta + ", sigma = " + configuration.sigma); MABED mabed = new MABED(); if (configuration.numberOfThreads > 1) { output += mabed.applyParallelized(corpus, configuration); } else { output += mabed.applyCentralized(corpus, configuration); } System.out.println( "--------------------\n" + Util.getDate() + " MABED ended\n--------------------"); output += "--------------------\n" + Util.getDate() + " MABED ended\n--------------------\n"; File outputDir = new File("output"); if (!outputDir.isDirectory()) { outputDir.mkdir(); } File textFile = new File("output/MABED.tex"); FileUtils.writeStringToFile(textFile, mabed.events.toLatex(corpus), false); textFile = new File("output/MABED.log"); FileUtils.writeStringToFile(textFile, output, false); mabed.events.printLatex(corpus); } catch (InterruptedException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } else { System.out.println("Unknown option '" + args[0] + "'\nType 'java -jar MABED.jar -help' for more information on how to run MABED"); } } }
From source file:TestDumpRecord.java
public static void main(String[] args) throws NITFException { List<String> argList = Arrays.asList(args); List<File> files = new LinkedList<File>(); for (String arg : argList) { File f = new File(arg); if (f.isDirectory()) { File[] dirFiles = f.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { String ext = FilenameUtils.getExtension(name).toLowerCase(); return ext.matches("nitf|nsf|ntf"); }//w w w .j a v a2 s . c o m }); files.addAll(Arrays.asList(dirFiles)); } else files.add(f); } Reader reader = new Reader(); for (File file : files) { PrintStream out = System.out; out.println("=== " + file.getAbsolutePath() + " ==="); IOHandle handle = new IOHandle(file.getAbsolutePath()); Record record = reader.read(handle); dumpRecord(record, reader, out); handle.close(); record.destruct(); // tells the memory manager to decrement the ref // count } }
From source file:com.taobao.tddl.common.SQLPreParserTest.java
public static void main(String[] args) throws IOException { //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-icsg-db0-db15-group-20100901100337-export.xlsx"; //String fileName = "D:/12_code/tddl/trunk/tddl/tddl-parser/sqlsummary-tcsg-instance-group-20100901100641-export.xlsx"; int count = 0; long time = 0; File home = new File(System.getProperty("user.dir") + "/appsqls"); for (File f : home.listFiles()) { if (f.isDirectory() || !f.getName().endsWith(".xlsx")) { continue; }/*from w ww . jav a 2s .c o m*/ log.info("---------------------- " + f.getAbsolutePath()); faillog.info("---------------------- " + f.getAbsolutePath()); Workbook wb = new XSSFWorkbook(new FileInputStream(f)); Sheet sheet = wb.getSheetAt(0); for (Row row : sheet) { Cell cell = row.getCell(2); if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING) { String sql = cell.getStringCellValue(); long t0 = System.currentTimeMillis(); String tableName = SQLPreParser.findTableName(sql); time += System.currentTimeMillis() - t0; count++; log.info(tableName + " <-- " + sql); if (tableName == null) { sql = sql.trim().toLowerCase(); if (isCRUD(sql)) { System.out.println("failed:" + sql); faillog.error("failed:" + sql); } } } } wb = null; } faillog.fatal("------------------------------- finished --------------------------"); faillog.fatal(count + " sql parsed, total time:" + time + ". average time use per sql:" + (double) time / count + "ms/sql"); }
From source file:eu.scape_project.arc2warc.Arc2WarcMigration.java
/** * Main entry point.//from w w w. ja va2 s . c o m * * @param args * @throws java.io.IOException * @throws org.apache.commons.cli.ParseException */ public static void main(String[] args) throws IOException, ParseException { Configuration conf = new Configuration(); // Command line interface config = new Arc2WarcMigrationConfig(); CommandLineParser cmdParser = new PosixParser(); GenericOptionsParser gop = new GenericOptionsParser(conf, args); Arc2WarcMigrationOptions a2wopt = new Arc2WarcMigrationOptions(); CommandLine cmd = cmdParser.parse(a2wopt.options, gop.getRemainingArgs()); if ((args.length == 0) || (cmd.hasOption(a2wopt.HELP_OPT))) { a2wopt.exit("Help", 0); } else { a2wopt.initOptions(cmd, config); } Arc2WarcMigration a2wm = new Arc2WarcMigration(); long startMillis = System.currentTimeMillis(); File input = new File(config.getInputStr()); if (input.isDirectory()) { config.setDirectoryInput(true); a2wm.traverseDir(input); } else { migrate(input); } long elapsedTimeMillis = System.currentTimeMillis() - startMillis; LOG.info("Processing time (sec): " + elapsedTimeMillis / 1000F); System.exit(0); }
From source file:Main.java
public static void main(String[] args) throws Exception { String destinationname = "d:\\"; byte[] buf = new byte[1024]; ZipInputStream zipinputstream = null; ZipEntry zipentry;/*from ww w. j ava2s .c om*/ zipinputstream = new ZipInputStream(new FileInputStream("fileName")); zipentry = zipinputstream.getNextEntry(); while (zipentry != null) { String entryName = zipentry.getName(); FileOutputStream fileoutputstream; File newFile = new File(entryName); String directory = newFile.getParent(); if (directory == null) { if (newFile.isDirectory()) break; } fileoutputstream = new FileOutputStream(destinationname + entryName); int n; while ((n = zipinputstream.read(buf, 0, 1024)) > -1) { fileoutputstream.write(buf, 0, n); } fileoutputstream.close(); zipinputstream.closeEntry(); zipentry = zipinputstream.getNextEntry(); } zipinputstream.close(); }
From source file:edu.cuhk.hccl.IDConverter.java
public static void main(String[] args) { if (args.length < 2) { printUsage();/*from www .j a va 2s .c o m*/ } try { File inFile = new File(args[0]); File outFile = new File(args[1]); if (inFile.isDirectory()) { System.out.println("ID Converting begins..."); FileUtils.forceMkdir(outFile); for (File file : inFile.listFiles()) { if (!file.isHidden()) processFile(file, new File(outFile.getAbsolutePath() + "/" + FilenameUtils.removeExtension(file.getName()) + "-long.txt")); } } else if (inFile.isFile()) { System.out.println("ID Converting begins..."); processFile(inFile, outFile); } else { printUsage(); } System.out.println("ID Converting finished."); } catch (IOException e) { e.printStackTrace(); } }