List of usage examples for java.io File getPath
public String getPath()
From source file:PKCS12Import.java
public static void main(String[] args) throws Exception { if (args.length < 1) { System.err.println("usage: java PKCS12Import {pkcs12file} [newjksfile]"); System.exit(1);/*from www.ja v a 2 s .co m*/ } File fileIn = new File(args[0]); File fileOut; if (args.length > 1) { fileOut = new File(args[1]); } else { fileOut = new File("newstore.jks"); } if (!fileIn.canRead()) { System.err.println("Unable to access input keystore: " + fileIn.getPath()); System.exit(2); } if (fileOut.exists() && !fileOut.canWrite()) { System.err.println("Output file is not writable: " + fileOut.getPath()); System.exit(2); } KeyStore kspkcs12 = KeyStore.getInstance("pkcs12"); KeyStore ksjks = KeyStore.getInstance("jks"); System.out.print("Enter input keystore passphrase: "); char[] inphrase = readPassphrase(); System.out.print("Enter output keystore passphrase: "); char[] outphrase = readPassphrase(); kspkcs12.load(new FileInputStream(fileIn), inphrase); ksjks.load((fileOut.exists()) ? new FileInputStream(fileOut) : null, outphrase); Enumeration eAliases = kspkcs12.aliases(); int n = 0; while (eAliases.hasMoreElements()) { String strAlias = (String) eAliases.nextElement(); System.err.println("Alias " + n++ + ": " + strAlias); if (kspkcs12.isKeyEntry(strAlias)) { System.err.println("Adding key for alias " + strAlias); Key key = kspkcs12.getKey(strAlias, inphrase); Certificate[] chain = kspkcs12.getCertificateChain(strAlias); ksjks.setKeyEntry(strAlias, key, outphrase, chain); } } OutputStream out = new FileOutputStream(fileOut); ksjks.store(out, outphrase); out.close(); }
From source file:languageTools.Analyzer.java
/** * * @param args// ww w . ja va2s .co m * @throws Exception */ public static void main(String[] args) { // Get start time. long startTime = System.nanoTime(); // Parse command line options File file; try { file = parseOptions(args); } catch (ParseException e) { System.out.println(e.getMessage()); showHelp(); return; } // Get all files that should be analyzed List<File> files = new ArrayList<File>(); if (file.isDirectory()) { // Search directory for indicated file types files = searchDirectory(file); System.out.println("Found " + files.size() + " file(s).\n"); } else { files.add(file); } // Process files found for (File filefound : files) { System.out.println("Processing file: " + filefound.getPath() + ".\n"); Validator<?, ?, ?, ?> validator = null; switch (Extension.getFileExtension(filefound)) { case GOAL: validator = new AgentValidator(filefound.getPath()); // TODO we need to set a KR interface; use default (only one) // right now. Best we can do now // is to ask user to set it. try { ((AgentValidator) validator).setKRInterface(KRFactory.getDefaultInterface()); } catch (KRInitFailedException e) { // TODO: use logger. System.out.println(e.getMessage()); } break; case MOD2G: validator = new ModuleValidator(filefound.getPath()); // TODO we need to set a KR interface; use default (only one) // right now. Best we can do now // is to ask user to set it. try { ((ModuleValidator) validator).setKRInterface(KRFactory.getDefaultInterface()); } catch (KRInitFailedException e) { // TODO: use logger. System.out.println(e.getMessage()); } break; case MAS2G: validator = new MASValidator(filefound.getPath()); break; case TEST2G: validator = new TestValidator(filefound.getPath()); break; default: // TODO: use logger. System.out.println("Expected file with extension 'goal', 'mas2g', 'mod2g', or 'test2g'"); continue; } // Validate program file validator.validate(); // Print lexer tokens if (lexer) { validator.printLexerTokens(); } // Print constructed program if (program) { System.out.println("\n\n" + validator.getProgram().toString(" ", " ")); } // Print report with warnings, and parsing and validation messages System.out.println(validator.report()); } // Get elapsed time. long elapsedTime = (System.nanoTime() - startTime) / 1000000; System.out.println("Took " + elapsedTime + " milliseconds to analyze " + files.size() + " file(s)."); }
From source file:com.sccl.attech.generate.Generate.java
/** * The main method./*from w w w . jav a2 s. c om*/ * * @param args the arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { // ========== ?? ====================1412914 // ?????? // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.sccl.attech.modules"; String moduleName = "mobil"; // ???sys String subModuleName = ""; // ????? String className = "updateApp"; // ??user List<GenerateField> fields = Lists.newArrayList(); fields.add(new GenerateField("name", "??")); fields.add(new GenerateField("type", "")); fields.add(new GenerateField("version", "")); fields.add(new GenerateField("path", "")); String classAuthor = "zzz"; // zhaozz String functionName = "App?"; // ?? // ??? //Boolean isEnable = false; Boolean isEnable = true; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; // ? File projectPath = new DefaultResourceLoader().getResource("").getFile(); while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) { projectPath = projectPath.getParentFile(); } logger.info("Project Path: {}", projectPath); // ? String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/sccl/attech/generate/template", "/", separator); logger.info("Template Path: {}", tplPath); // Java String javaPath = StringUtils.replaceEach( projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." }, new String[] { separator, separator }); logger.info("Java Path: {}", javaPath); // String viewPath = StringUtils.replace(projectPath + "/WebRoot/pages", "/", separator); logger.info("View Path: {}", viewPath); String resPath = StringUtils.replace(projectPath + "/WebRoot/assets/js", "/", separator); logger.info("Res Path: {}", resPath); // ??? Configuration cfg = new Configuration(); cfg.setDefaultEncoding("UTF-8"); cfg.setDirectoryForTemplateLoading(new File(tplPath)); // ??? Map<String, Object> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("fields", fields); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+ model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info("Entity: {}", filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info("Dao: {}", filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info("Service: {}", filePath); // ? Controller createJavaFile(subModuleName, separator, javaPath, cfg, model); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.html"; writeFile(content, filePath); logger.info("ViewForm: {}", filePath); // ? ViewFormJs template = cfg.getTemplate("viewFormJs.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = resPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "FormCtrl.js"; writeFile(content, filePath); logger.info("ViewFormJs: {}", filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.html"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); // ? ViewListJs template = cfg.getTemplate("viewListJs.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = resPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "ListCtrl.js"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); // ? ??sql template = cfg.getTemplate("sql.ftl"); model.put("uid", IdGen.uuid()); model.put("uid1", IdGen.uuid()); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + ".sql"; writeFile(content, filePath); logger.info("ViewList: {}", filePath); logger.info("Generate Success."); }
From source file:com.github.lgi2p.obirs.utils.JSONConverter.java
public static void main(String[] args) throws Exception { String annotdir = "/data/toxnuc/toxnuc_annots_5_11_14/annots"; String annotsIndex = "/data/toxnuc/toxnuc_annots_5_11_14.json"; File folder = new File(annotdir); File[] listOfFiles = folder.listFiles(); PrintWriter printWriter = new PrintWriter(annotsIndex); int i = 0;//w w w. j a va2 s . c o m for (File file : listOfFiles) { if (file.isFile()) { System.out.println(file.getPath()); String title = file.getName(); String href = file.getPath(); String json = toJSONindexFormat(i, title, Utils.readFileAsString(file), href); i++; printWriter.println(json); } } printWriter.close(); System.out.println("consult: " + annotsIndex); }
From source file:com.xinge.sample.samples.docx4j.org.docx4j.samples.OpenUnzippedAndSaveZipped.java
public static void main(String[] args) throws Exception { try {/*from www . ja v a 2s .c om*/ getInputFilePath(args); } catch (IllegalArgumentException e) { inputfilepath = System.getProperty("user.dir") + "/OUT"; } System.out.println(inputfilepath); // Load the docx File baseDir = new File(inputfilepath); UnzippedPartStore partLoader = new UnzippedPartStore(baseDir); final Load3 loader = new Load3(partLoader); OpcPackage opc = loader.get(); // Save it zipped File docxFile = new File(System.getProperty("user.dir") + "/zip.docx"); ZipPartStore zps = new ZipPartStore(); zps.setSourcePartStore(opc.getSourcePartStore()); Save saver = new Save(opc, zps); FileOutputStream fos = null; try { fos = new FileOutputStream(docxFile); saver.save(fos); } catch (FileNotFoundException e) { throw new Docx4JException("Couldn't save " + docxFile.getPath(), e); } finally { IOUtils.closeQuietly(fos); } }
From source file:GIST.IzbirkomExtractor.IzbirkomExtractor.java
/** * @param args/*ww w . j a v a2 s. c o m*/ */ public static void main(String[] args) { // process command-line options Options options = new Options(); options.addOption("n", "noaddr", false, "do not do any address matching (for testing)"); options.addOption("i", "info", false, "create and populate address information table"); options.addOption("h", "help", false, "this message"); // database connection options.addOption("s", "server", true, "database server to connect to"); options.addOption("d", "database", true, "OSM database name"); options.addOption("u", "user", true, "OSM database user name"); options.addOption("p", "pass", true, "OSM database password"); // logging options options.addOption("l", "logdir", true, "log file directory (default './logs')"); options.addOption("e", "loglevel", true, "log level (default 'FINEST')"); // automatically generate the help statement HelpFormatter help_formatter = new HelpFormatter(); // database URI for connection String dburi = null; // Information message for help screen String info_msg = "IzbirkomExtractor [options] <html_directory>"; try { CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('h') || cmd.getArgs().length != 1) { help_formatter.printHelp(info_msg, options); System.exit(1); } /* prohibit n and i together */ if (cmd.hasOption('n') && cmd.hasOption('i')) { System.err.println("Options 'n' and 'i' cannot be used together."); System.exit(1); } /* require database arguments without -n */ if (cmd.hasOption('n') && (cmd.hasOption('s') || cmd.hasOption('d') || cmd.hasOption('u') || cmd.hasOption('p'))) { System.err.println("Options 'n' and does not need any databse parameters."); System.exit(1); } /* require all 4 database options to be used together */ if (!cmd.hasOption('n') && !(cmd.hasOption('s') && cmd.hasOption('d') && cmd.hasOption('u') && cmd.hasOption('p'))) { System.err.println( "For database access all of the following arguments have to be specified: server, database, user, pass"); System.exit(1); } /* useful variables */ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm"); String dateString = formatter.format(new Date()); /* setup logging */ File logdir = new File(cmd.hasOption('l') ? cmd.getOptionValue('l') : "logs"); FileUtils.forceMkdir(logdir); File log_file_name = new File( logdir + "/" + IzbirkomExtractor.class.getName() + "-" + formatter.format(new Date()) + ".log"); FileHandler log_file = new FileHandler(log_file_name.getPath()); /* create "latest" link to currently created log file */ Path latest_log_link = Paths.get(logdir + "/latest"); Files.deleteIfExists(latest_log_link); Files.createSymbolicLink(latest_log_link, Paths.get(log_file_name.getName())); log_file.setFormatter(new SimpleFormatter()); LogManager.getLogManager().reset(); // prevents logging to console logger.addHandler(log_file); logger.setLevel(cmd.hasOption('e') ? Level.parse(cmd.getOptionValue('e')) : Level.FINEST); // open directory with HTML files and create file list File dir = new File(cmd.getArgs()[0]); if (!dir.isDirectory()) { System.err.println("Unable to find directory '" + cmd.getArgs()[0] + "', exiting"); System.exit(1); } PathMatcher pmatcher = FileSystems.getDefault() .getPathMatcher("glob:? * ?*.html"); ArrayList<File> html_files = new ArrayList<>(); for (Path file : Files.newDirectoryStream(dir.toPath())) if (pmatcher.matches(file.getFileName())) html_files.add(file.toFile()); if (html_files.size() == 0) { System.err.println("No matching HTML files found in '" + dir.getAbsolutePath() + "', exiting"); System.exit(1); } // create csvResultSink FileOutputStream csvout_file = new FileOutputStream("parsed_addresses-" + dateString + ".csv"); OutputStreamWriter csvout = new OutputStreamWriter(csvout_file, "UTF-8"); ResultSink csvResultSink = new CSVResultSink(csvout, new CSVStrategy('|', '"', '#')); // Connect to DB and osmAddressMatcher AddressMatcher osmAddressMatcher; DBSink dbSink = null; DBInfoSink dbInfoSink = null; if (cmd.hasOption('n')) { osmAddressMatcher = new DummyAddressMatcher(); } else { dburi = "jdbc:postgresql://" + cmd.getOptionValue('s') + "/" + cmd.getOptionValue('d'); Connection con = DriverManager.getConnection(dburi, cmd.getOptionValue('u'), cmd.getOptionValue('p')); osmAddressMatcher = new OsmAddressMatcher(con); dbSink = new DBSink(con); if (cmd.hasOption('i')) dbInfoSink = new DBInfoSink(con); } /* create resultsinks */ SinkMultiplexor sm = SinkMultiplexor.newSinkMultiplexor(); sm.addResultSink(csvResultSink); if (dbSink != null) { sm.addResultSink(dbSink); if (dbInfoSink != null) sm.addResultSink(dbInfoSink); } // create tableExtractor TableExtractor te = new TableExtractor(osmAddressMatcher, sm); // TODO: printout summary of options: processing date/time, host, directory of HTML files, jdbc uri, command line with parameters // iterate through files logger.info("Start processing " + html_files.size() + " files in " + dir); for (int i = 0; i < html_files.size(); i++) { System.err.println("Parsing #" + i + ": " + html_files.get(i)); te.processHTMLfile(html_files.get(i)); } System.err.println("Processed " + html_files.size() + " HTML files"); logger.info("Finished processing " + html_files.size() + " files in " + dir); } catch (ParseException e1) { System.err.println("Failed to parse CLI: " + e1.getMessage()); help_formatter.printHelp(info_msg, options); System.exit(1); } catch (IOException e) { System.err.println("I/O Exception: " + e.getMessage()); e.printStackTrace(); System.exit(1); } catch (SQLException e) { System.err.println("Database '" + dburi + "': " + e.getMessage()); System.exit(1); } catch (ResultSinkException e) { System.err.println("Failed to initialize ResultSink: " + e.getMessage()); System.exit(1); } catch (TableExtractorException e) { System.err.println("Failed to initialize Table Extractor: " + e.getMessage()); System.exit(1); } catch (CloneNotSupportedException | IllegalAccessException | InstantiationException e) { System.err.println("Something really odd happened: " + e.getMessage()); e.printStackTrace(); System.exit(1); } }
From source file:enrichment.Disambiguate.java
/**prerequisites: * cd silk_2.5.3/*_links//w w w. j a v a 2s .c o m * cat *.nt|sort -t' ' -k3 > $filename * * @param args $filename * @throws IOException * @throws URISyntaxException */ public static void main(String[] args) { File file = new File(args[0]); if (file.isDirectory()) { args = file.list(new OnlyExtFilenameFilter("nt")); } BufferedReader in; for (int q = 0; q < args.length; q++) { String filename = null; if (file.isDirectory()) { filename = file.getPath() + File.separator + args[q]; } else { filename = args[q]; } try { FileWriter output = new FileWriter(filename + "_disambiguated.nt"); String prefix = "@prefix rdrel: <http://rdvocab.info/RDARelationshipsWEMI/> .\n" + "@prefix dbpedia: <http://de.dbpedia.org/resource/> .\n" + "@prefix frbr: <http://purl.org/vocab/frbr/core#> .\n" + "@prefix lobid: <http://lobid.org/resource/> .\n" + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" + "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n" + "@prefix mo: <http://purl.org/ontology/mo/> .\n" + "@prefix wikipedia: <https://de.wikipedia.org/wiki/> ."; output.append(prefix + "\n\n"); in = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); HashMap<String, HashMap<String, ArrayList<String>>> hm = new HashMap<String, HashMap<String, ArrayList<String>>>(); String s; HashMap<String, ArrayList<String>> hmLobid = new HashMap<String, ArrayList<String>>(); Stack<String> old_object = new Stack<String>(); while ((s = in.readLine()) != null) { String[] triples = s.split(" "); String object = triples[2].substring(1, triples[2].length() - 1); if (old_object.size() > 0 && !old_object.firstElement().equals(object)) { hmLobid = new HashMap<String, ArrayList<String>>(); old_object = new Stack<String>(); } old_object.push(object); String subject = triples[0].substring(1, triples[0].length() - 1); System.out.print("\nSubject=" + object); System.out.print("\ntriples[2]=" + triples[2]); hmLobid.put(subject, getAllCreators(new URI(subject))); hm.put(object, hmLobid); } // get all dbpedia resources for (String key_one : hm.keySet()) { System.out.print("\n==============\n==== " + key_one + "\n==============="); int resources_cnt = hm.get(key_one).keySet().size(); ArrayList<String>[] creators = new ArrayList[resources_cnt]; HashMap<String, Integer> creators_backed = new HashMap<String, Integer>(); int x = 0; // get all lobid_resources subsumed under the dbpedia resource for (String subject_uri : hm.get(key_one).keySet()) { creators[x] = new ArrayList<String>(); System.out.print("\n subject_uri=" + subject_uri); Iterator<String> ite = hm.get(key_one).get(subject_uri).iterator(); int y = 0; // get all creators of the lobid resource while (ite.hasNext()) { String creator = ite.next(); System.out.print("\n " + creator); if (creators_backed.containsKey(creator)) { y = creators_backed.get(creator); } else { y = creators_backed.size(); creators_backed.put(creator, y); } while (creators[x].size() <= y) { creators[x].add("-"); } creators[x].set(y, creator); y++; } x++; } if (creators_backed.size() == 1) { System.out .println("\n" + "Every resource pointing to " + key_one + " has the same creator!"); for (String key_two : hm.get(key_one).keySet()) { output.append("<" + key_two + "> rdrel:workManifested <" + key_one + "> .\n"); output.append("<" + key_two + "> mo:wikipedia <" + key_one.replaceAll("dbpedia\\.org/resource", "wikipedia\\.org/wiki") + "> .\n"); } } /*else { for (int a = 0; a < creators.length; a++) { System.out.print(creators[a].toString()+","); } }*/ } output.flush(); if (output != null) { output.close(); } } catch (Exception e) { System.out.print("Exception while working on " + filename + ": \n"); e.printStackTrace(System.out); } } }
From source file:comparetopics.CompareTwoGroupTopics.java
public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("please input the path for File1: "); String filepath1 = sc.nextLine(); System.out.println("please input the path for File2: "); String filepath2 = sc.nextLine(); try {//from www.j a va2s . c o m File file1 = new File(filepath1); File file2 = new File(filepath2); System.out.println("File1: " + filepath1); System.out.println("File2: " + filepath2); if (!file1.exists()) { System.out.println("File1 isn't exist"); } else if (!file2.exists()) { System.out.println("File2 isn't exist"); } else { try (InputStream in1 = new FileInputStream(file1.getPath()); BufferedReader reader1 = new BufferedReader(new InputStreamReader(in1))) { String line1 = null; int lineNr1 = -1; while ((line1 = reader1.readLine()) != null) { ++lineNr1; int lineNr2 = -1; String line2 = null; try (InputStream in2 = new FileInputStream(file2.getPath()); BufferedReader reader2 = new BufferedReader(new InputStreamReader(in2))) { while ((line2 = reader2.readLine()) != null) { ++lineNr2; compareTwoGroups(line1, line2, lineNr1, lineNr2); } } System.out.println(); } } } } catch (IOException ex) { Logger.getLogger(CompareTopics.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.errantlinguist.latticevisualiser.LatticeVisualiser.java
/** * Parses command-line arguments for input file, window width and height, * minimum state (i.e. vertex) size and the state/vertex size * multiplier. The input file is then read and visualised. * /* www .j a v a 2 s . c o m*/ * @param args * The command-line arguments. */ public static void main(final String[] args) { final ArgParser argParser = ArgParser.getInstance(); argParser.parseArgs(args); System.out.print("Reading lattice from path: "); final File latticeInfile = argParser.getLatticeInfile(); System.out.println(latticeInfile.getPath()); DirectedSparseGraph<Integer, Edge> latticeGraph = null; try { latticeGraph = readLattice(latticeInfile); } catch (final IOException e) { System.err.println("I/O exception while reading lattice file."); e.printStackTrace(); System.exit(EX_IOERR); } catch (final ParseException e) { System.err.println("Parse exception while reading lattice file."); e.printStackTrace(); System.exit(EX_DATAERR); } final File nonwordInfile = argParser.getNonwordsInfile(); ImmutableSet<String> nonwords = null; try { nonwords = readNonwordLabelSet(nonwordInfile); } catch (final IOException e) { System.err.println("I/O exception while reading non-word label file."); e.printStackTrace(); System.exit(EX_IOERR); } catch (final ParseException e) { System.err.println("Parse exception while reading non-word label file."); e.printStackTrace(); System.exit(EX_DATAERR); } // Set the set of symbols which represent non-word labels. NOTE: // This has to be set in order for most of the visualisation to work // properly. StateType.setNonwords(nonwords); final Dimension windowDimension = argParser.getWindowDimension(); final double stateSizeMultiplier = argParser.getStateSizeMultiplier(); final int minStateSize = argParser.getMinStateSize(); final LatticeVisualiser visualizer = new LatticeVisualiser(latticeGraph, nonwords, windowDimension, stateSizeMultiplier, minStateSize); visualizer.visualise(); visualizer.show(); printInfo(latticeGraph); }
From source file:com.zilotti.hostsjuggler.view.ActiveHostsFileWindow.java
/** * @param args/* w w w . j a v a 2s . c o m*/ */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub /* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments) * for the correct SWT library path in order to run with the SWT dlls. * The dlls are located in the SWT plugin jar. * For example, on Windows the Eclipse SWT 3.1 plugin jar is: * installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar */ Display display = Display.getDefault(); ActiveHostsFileWindow thisClass = new ActiveHostsFileWindow(); thisClass.createSShell(); thisClass.sShell.open(); /* * Loads active hosts file */ File activeHostsFile = getActiveHostsFile(); thisClass.highlightActiveHostsFile(activeHostsFile); thisClass.label.setText("Current hosts file (located at " + activeHostsFile.getPath() + ")"); HostsFile hf = thisClass.loadHostsFile(activeHostsFile); System.out.println("Lines: " + hf.getHostsFileLines().size()); HostsFileDAO hfDAO = new HostsFileSerializationDAO(); hfDAO.save(hf); while (!thisClass.sShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }