List of usage examples for java.io File getAbsolutePath
public String getAbsolutePath()
From source file:edu.ucdenver.ccp.nlp.ae.dict_util.GeneInfoToDictionary.java
public static void main(String args[]) { BasicConfigurator.configure();/*from w ww . ja va 2 s . co m*/ if (args.length < 2) { usage(); } else { try { File geneFile = new File(args[0]); File outputFile = new File(args[1]); if (!geneFile.canRead()) { System.out.println("can't read input file;" + geneFile.getAbsolutePath()); usage(); System.exit(-2); } if (outputFile.exists() && !outputFile.canWrite()) { System.out.println("can't write output file;" + outputFile.getAbsolutePath()); usage(); System.exit(-3); } logger.warn("running with: " + geneFile.getAbsolutePath()); GeneInfoToDictionary converter = new GeneInfoToDictionary(geneFile); converter.convert(geneFile, outputFile); } catch (Exception e) { System.out.println("error:" + e); e.printStackTrace(); System.exit(-1); } } }
From source file:act.installer.reachablesexplorer.PatentFinder.java
public static void main(String[] args) throws Exception { CLIUtil cliUtil = new CLIUtil(Loader.class, HELP_MESSAGE, OPTION_BUILDERS); CommandLine cl = cliUtil.parseCommandLine(args); String host = cl.getOptionValue(OPTION_DB_HOST, DEFAULT_HOST); Integer port = Integer.parseInt(cl.getOptionValue(OPTION_DB_PORT, DEFAULT_PORT.toString())); String targetDB = cl.getOptionValue(OPTION_TARGET_DB, DEFAULT_TARGET_DATABASE); String collection = cl.getOptionValue(OPTION_TARGET_REACHABLES_COLLECTION, DEFAULT_TARGET_COLLECTION); LOGGER.info("Connecting to %s:%d/%s, using collection %s", host, port, targetDB, collection); Loader loader = new Loader(host, port, UNUSED_SOURCE_DB, targetDB, collection, UNUSED_SEQUENCES_COLLECTION, UNUSED_ASSETS_DIR);//w w w . j a va 2s . com File indexesTopDir = new File(cl.getOptionValue(OPTION_PATENT_INDEX_DIR, DEFAULT_PATENT_INDEX_LOCATION)); if (!indexesTopDir.exists() || !indexesTopDir.isDirectory()) { cliUtil.failWithMessage("Index top-level directory at %s is not a directory", indexesTopDir.getAbsolutePath()); } LOGGER.info("Using index top level dir: %s", indexesTopDir.getAbsolutePath()); PatentFinder finder = new PatentFinder(); try (Searcher searcher = Searcher.Factory.getInstance().build(indexesTopDir)) { finder.run(loader, searcher); } }
From source file:com.amazonaws.services.kinesis.clientlibrary.proxies.util.KinesisLocalFileDataCreator.java
/** Creates a new temp file populated with fake Kinesis data records. * @param args Expects 5 args: numShards, shardPrefix, numRecordsPerShard, startingSequenceNumber, fileNamePrefix *//* ww w .j a v a 2s .c o m*/ // CHECKSTYLE:OFF MagicNumber // CHECKSTYLE:IGNORE UncommentedMain FOR NEXT 2 LINES public static void main(String[] args) { int numShards = 1; String shardIdPrefix = "shardId"; int numRecordsPerShard = 17; BigInteger startingSequenceNumber = new BigInteger("99"); String fileNamePrefix = "kinesisFakeRecords"; try { if ((args.length != 0) && (args.length != 5)) { // Temporary util code, so not providing detailed usage feedback. System.out.println("Unexpected number of arguments."); System.exit(0); } if (args.length == 5) { numShards = Integer.parseInt(args[0]); shardIdPrefix = args[1]; numRecordsPerShard = Integer.parseInt(args[2]); startingSequenceNumber = new BigInteger(args[3]); fileNamePrefix = args[4]; } File file = KinesisLocalFileDataCreator.generateTempDataFile(numShards, shardIdPrefix, numRecordsPerShard, startingSequenceNumber, fileNamePrefix); System.out.println("Created fake kinesis records in file: " + file.getAbsolutePath()); } catch (Exception e) { // CHECKSTYLE:IGNORE IllegalCatch FOR NEXT -1 LINES System.out.println("Caught Exception: " + e); } }
From source file:com.act.lcms.db.analysis.FeedingAnalysis.java
public static void main(String[] args) throws Exception { Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());//from www.j a va 2 s .c om } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY)); if (!lcmsDir.isDirectory()) { System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath()); HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } try (DB db = DB.openDBFromCLI(cl)) { System.out.format("Loading/updating LCMS scan files into DB\n"); ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir); System.out.format("Running feeding analysis\n"); performFeedingAnalysis(db, cl.getOptionValue(OPTION_DIRECTORY), cl.getOptionValue(OPTION_ION_NAME), cl.getOptionValue(OPTION_SEARCH_MZ), cl.getOptionValue(OPTION_PLATE_BARCODE), cl.getOptionValue(OPTION_FEEDING_STRAIN_OR_CONSTRUCT), cl.getOptionValue(OPTION_FEEDING_EXTRACT), cl.getOptionValue(OPTION_FEEDING_FED_CHEMICAL), cl.getOptionValue(OPTION_OUTPUT_PREFIX), "pdf"); } }
From source file:edu.cmu.lti.oaqa.knn4qa.apps.LuceneIndexer.java
public static void main(String[] args) { Options options = new Options(); options.addOption(CommonParams.ROOT_DIR_PARAM, null, true, CommonParams.ROOT_DIR_DESC); options.addOption(CommonParams.SUB_DIR_TYPE_PARAM, null, true, CommonParams.SUB_DIR_TYPE_DESC); options.addOption(CommonParams.MAX_NUM_REC_PARAM, null, true, CommonParams.MAX_NUM_REC_DESC); options.addOption(CommonParams.SOLR_FILE_NAME_PARAM, null, true, CommonParams.SOLR_FILE_NAME_DESC); options.addOption(CommonParams.OUT_INDEX_PARAM, null, true, CommonParams.OUT_MINDEX_DESC); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try {/*from ww w . jav a2 s . c om*/ CommandLine cmd = parser.parse(options, args); String rootDir = null; rootDir = cmd.getOptionValue(CommonParams.ROOT_DIR_PARAM); if (null == rootDir) Usage("Specify: " + CommonParams.ROOT_DIR_DESC, options); String outputDirName = cmd.getOptionValue(CommonParams.OUT_INDEX_PARAM); if (null == outputDirName) Usage("Specify: " + CommonParams.OUT_MINDEX_DESC, options); String subDirTypeList = cmd.getOptionValue(CommonParams.SUB_DIR_TYPE_PARAM); if (null == subDirTypeList || subDirTypeList.isEmpty()) Usage("Specify: " + CommonParams.SUB_DIR_TYPE_DESC, options); String solrFileName = cmd.getOptionValue(CommonParams.SOLR_FILE_NAME_PARAM); if (null == solrFileName) Usage("Specify: " + CommonParams.SOLR_FILE_NAME_DESC, options); int maxNumRec = Integer.MAX_VALUE; String tmp = cmd.getOptionValue(CommonParams.MAX_NUM_REC_PARAM); if (tmp != null) { try { maxNumRec = Integer.parseInt(tmp); if (maxNumRec <= 0) { Usage("The maximum number of records should be a positive integer", options); } } catch (NumberFormatException e) { Usage("The maximum number of records should be a positive integer", options); } } File outputDir = new File(outputDirName); if (!outputDir.exists()) { if (!outputDir.mkdirs()) { System.out.println("couldn't create " + outputDir.getAbsolutePath()); System.exit(1); } } if (!outputDir.isDirectory()) { System.out.println(outputDir.getAbsolutePath() + " is not a directory!"); System.exit(1); } if (!outputDir.canWrite()) { System.out.println("Can't write to " + outputDir.getAbsolutePath()); System.exit(1); } String subDirs[] = subDirTypeList.split(","); int docNum = 0; // No English analyzer here, all language-related processing is done already, // here we simply white-space tokenize and index tokens verbatim. Analyzer analyzer = new WhitespaceAnalyzer(); FSDirectory indexDir = FSDirectory.open(outputDir); IndexWriterConfig indexConf = new IndexWriterConfig(analyzer.getVersion(), analyzer); System.out.println("Creating a new Lucene index, maximum # of docs to process: " + maxNumRec); indexConf.setOpenMode(OpenMode.CREATE); IndexWriter indexWriter = new IndexWriter(indexDir, indexConf); for (int subDirId = 0; subDirId < subDirs.length && docNum < maxNumRec; ++subDirId) { String inputFileName = rootDir + "/" + subDirs[subDirId] + "/" + solrFileName; System.out.println("Input file name: " + inputFileName); BufferedReader inpText = new BufferedReader( new InputStreamReader(CompressUtils.createInputStream(inputFileName))); String docText = XmlHelper.readNextXMLIndexEntry(inpText); for (; docText != null && docNum < maxNumRec; docText = XmlHelper.readNextXMLIndexEntry(inpText)) { ++docNum; Map<String, String> docFields = null; Document luceneDoc = new Document(); try { docFields = XmlHelper.parseXMLIndexEntry(docText); } catch (Exception e) { System.err.println(String.format("Parsing error, offending DOC #%d:\n%s", docNum, docText)); System.exit(1); } String id = docFields.get(UtilConst.TAG_DOCNO); if (id == null) { System.err.println(String.format("No ID tag '%s', offending DOC #%d:\n%s", UtilConst.TAG_DOCNO, docNum, docText)); } luceneDoc.add(new StringField(UtilConst.TAG_DOCNO, id, Field.Store.YES)); for (Map.Entry<String, String> e : docFields.entrySet()) if (!e.getKey().equals(UtilConst.TAG_DOCNO)) { luceneDoc.add(new TextField(e.getKey(), e.getValue(), Field.Store.YES)); } indexWriter.addDocument(luceneDoc); if (docNum % 1000 == 0) System.out.println("Indexed " + docNum + " docs"); } System.out.println("Indexed " + docNum + " docs"); } indexWriter.commit(); indexWriter.close(); } catch (ParseException e) { Usage("Cannot parse arguments", options); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:gov.lanl.adore.djatoka.DjatokaCompress.java
/** * Uses apache commons cli to parse input args. Passes parsed * parameters to ICompress implementation. * @param args command line parameters to defined input,output,etc. */// www . j a v a 2 s.co m public static void main(String[] args) { // create the command line parser CommandLineParser parser = new PosixParser(); // create the Options Options options = new Options(); options.addOption("i", "input", true, "Filepath of the input file or dir."); options.addOption("o", "output", true, "Filepath of the output file or dir."); options.addOption("r", "rate", true, "Absolute Compression Ratio"); options.addOption("s", "slope", true, "Used to generate relative compression ratio based on content characteristics."); options.addOption("y", "Clayers", true, "Number of quality levels."); options.addOption("l", "Clevels", true, "Number of DWT levels (reolution levels)."); options.addOption("v", "Creversible", true, "Use Reversible Wavelet"); options.addOption("c", "Cprecincts", true, "Precinct dimensions"); options.addOption("p", "props", true, "Compression Properties File"); options.addOption("d", "Corder", true, "Progression order"); options.addOption("g", "ORGgen_plt", true, "Enables insertion of packet length information in the header"); options.addOption("t", "ORGtparts", true, "Division of each tile's packets into tile-parts"); options.addOption("b", "Cblk", true, "Codeblock Size"); options.addOption("a", "AltImpl", true, "Alternate ICompress Implemenation"); try { if (args.length == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("gov.lanl.adore.djatoka.DjatokaCompress", options); System.exit(0); } // parse the command line arguments CommandLine line = parser.parse(options, args); String input = line.getOptionValue("i"); String output = line.getOptionValue("o"); String propsFile = line.getOptionValue("p"); DjatokaEncodeParam p; if (propsFile != null) { Properties props = IOUtils.loadConfigByPath(propsFile); p = new DjatokaEncodeParam(props); } else p = new DjatokaEncodeParam(); String rate = line.getOptionValue("r"); if (rate != null) p.setRate(rate); String slope = line.getOptionValue("s"); if (slope != null) p.setSlope(slope); String Clayers = line.getOptionValue("y"); if (Clayers != null) p.setLayers(Integer.parseInt(Clayers)); String Clevels = line.getOptionValue("l"); if (Clevels != null) p.setLevels(Integer.parseInt(Clevels)); String Creversible = line.getOptionValue("v"); if (Creversible != null) p.setUseReversible(Boolean.parseBoolean(Creversible)); String Cprecincts = line.getOptionValue("c"); if (Cprecincts != null) p.setPrecincts(Cprecincts); String Corder = line.getOptionValue("d"); if (Corder != null) p.setProgressionOrder(Corder); String ORGgen_plt = line.getOptionValue("g"); if (ORGgen_plt != null) p.setInsertPLT(Boolean.parseBoolean(ORGgen_plt)); String Cblk = line.getOptionValue("b"); if (Cblk != null) p.setCodeBlockSize(Cblk); String alt = line.getOptionValue("a"); ICompress jp2 = new KduCompressExe(); if (alt != null) jp2 = (ICompress) Class.forName(alt).newInstance(); if (new File(input).isDirectory() && new File(output).isDirectory()) { ArrayList<File> files = IOUtils.getFileList(input, new SourceImageFileFilter(), false); for (File f : files) { long x = System.currentTimeMillis(); File outFile = new File(output, f.getName().substring(0, f.getName().indexOf(".")) + ".jp2"); compress(jp2, f.getAbsolutePath(), outFile.getAbsolutePath(), p); report(f.getAbsolutePath(), x); } } else { long x = System.currentTimeMillis(); File f = new File(input); if (output == null) output = f.getName().substring(0, f.getName().indexOf(".")) + ".jp2"; if (new File(output).isDirectory()) output = output + f.getName().substring(0, f.getName().indexOf(".")) + ".jp2"; compress(jp2, input, output, p); report(input, x); } } catch (ParseException e) { logger.error("Parse exception:" + e.getMessage(), e); } catch (DjatokaException e) { logger.error("djatoka Compression exception:" + e.getMessage(), e); } catch (InstantiationException e) { logger.error("Unable to initialize alternate implemenation:" + e.getMessage(), e); } catch (Exception e) { logger.error("An exception occured:" + e.getMessage(), e); } }
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();// w ww. ja v a2 s. c o m for (String name : remapper.getObfedClasses()) { // Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name)); String fileName = name; 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:DIA_Umpire_Quant.DIA_Umpire_LCMSIDGen.java
/** * @param args the command line arguments */// w ww . jav a 2 s .c o m public static void main(String[] args) throws FileNotFoundException, IOException, Exception { System.out.println( "================================================================================================="); System.out.println("DIA-Umpire LCMSID geneartor (version: " + UmpireInfo.GetInstance().Version + ")"); if (args.length != 1) { System.out.println( "command format error, the correct format should be: java -jar -Xmx10G DIA_Umpire_LCMSIDGen.jar diaumpire_module.params"); return; } try { ConsoleLogger.SetConsoleLogger(Level.INFO); ConsoleLogger.SetFileLogger(Level.DEBUG, FilenameUtils.getFullPath(args[0]) + "diaumpire_lcmsidgen.log"); } catch (Exception e) { } Logger.getRootLogger().info("Version: " + UmpireInfo.GetInstance().Version); Logger.getRootLogger().info("Parameter file:" + args[0]); BufferedReader reader = new BufferedReader(new FileReader(args[0])); String line = ""; String WorkFolder = ""; int NoCPUs = 2; TandemParam tandemPara = new TandemParam(DBSearchParam.SearchInstrumentType.TOF5600); HashMap<String, File> AssignFiles = new HashMap<>(); //<editor-fold defaultstate="collapsed" desc="Reading parameter file"> while ((line = reader.readLine()) != null) { line = line.trim(); Logger.getRootLogger().info(line); if (!"".equals(line) && !line.startsWith("#")) { //System.out.println(line); if (line.equals("==File list begin")) { do { line = reader.readLine(); line = line.trim(); if (line.equals("==File list end")) { continue; } else if (!"".equals(line)) { File newfile = new File(line); if (newfile.exists()) { AssignFiles.put(newfile.getAbsolutePath(), newfile); } else { Logger.getRootLogger().info("File: " + newfile + " does not exist."); } } } while (!line.equals("==File list end")); } if (line.split("=").length < 2) { continue; } String type = line.split("=")[0].trim(); String value = line.split("=")[1].trim(); switch (type) { case "Path": { WorkFolder = value; break; } case "path": { WorkFolder = value; break; } case "Thread": { NoCPUs = Integer.parseInt(value); break; } case "DecoyPrefix": { if (!"".equals(value)) { tandemPara.DecoyPrefix = value; } break; } case "PeptideFDR": { tandemPara.PepFDR = Float.parseFloat(value); break; } } } } //</editor-fold> //Initialize PTM manager using compomics library PTMManager.GetInstance(); //Generate DIA file list ArrayList<DIAPack> FileList = new ArrayList<>(); File folder = new File(WorkFolder); if (!folder.exists()) { Logger.getRootLogger().info("The path : " + WorkFolder + " cannot be found."); System.exit(1); } for (final File fileEntry : folder.listFiles()) { if (fileEntry.isFile() && (fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzxml") | fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzml")) && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q1.mzxml") && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q2.mzxml") && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) { AssignFiles.put(fileEntry.getAbsolutePath(), fileEntry); } if (fileEntry.isDirectory()) { for (final File fileEntry2 : fileEntry.listFiles()) { if (fileEntry2.isFile() && (fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzxml") | fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzml")) && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q1.mzxml") && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q2.mzxml") && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) { AssignFiles.put(fileEntry2.getAbsolutePath(), fileEntry2); } } } } Logger.getRootLogger().info("No. of files assigned :" + AssignFiles.size()); for (File fileEntry : AssignFiles.values()) { Logger.getRootLogger().info(fileEntry.getAbsolutePath()); } //process each DIA file to genearate untargeted identifications for (File fileEntry : AssignFiles.values()) { String mzXMLFile = fileEntry.getAbsolutePath(); if (mzXMLFile.toLowerCase().endsWith(".mzxml") | mzXMLFile.toLowerCase().endsWith(".mzml")) { long time = System.currentTimeMillis(); DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs); FileList.add(DiaFile); Logger.getRootLogger().info( "================================================================================================="); Logger.getRootLogger().info("Processing " + mzXMLFile); if (!DiaFile.LoadDIASetting()) { Logger.getRootLogger().info("Loading DIA setting failed, job is incomplete"); System.exit(1); } if (!DiaFile.LoadParams()) { Logger.getRootLogger().info("Loading parameters failed, job is incomplete"); System.exit(1); } Logger.getRootLogger().info("Loading identification results " + mzXMLFile + "...."); DiaFile.ParsePepXML(tandemPara, null); DiaFile.BuildStructure(); if (!DiaFile.MS1FeatureMap.ReadPeakCluster()) { Logger.getRootLogger().info("Loading peak and structure failed, job is incomplete"); System.exit(1); } DiaFile.MS1FeatureMap.ClearMonoisotopicPeakOfCluster(); //Generate mapping between index of precursor feature and pseudo MS/MS scan index DiaFile.GenerateClusterScanNomapping(); //Doing quantification DiaFile.AssignQuant(); DiaFile.ClearStructure(); DiaFile.IDsummary.ReduceMemoryUsage(); time = System.currentTimeMillis() - time; Logger.getRootLogger().info(mzXMLFile + " processed time:" + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time), TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)), TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time)))); } Logger.getRootLogger().info("Job done"); Logger.getRootLogger().info( "================================================================================================="); } }
From source file:com.timothyyip.face.FaceDetector.java
public static void main(String[] args) throws ImageReadException, IOException, ImageWriteException { Detector detector = new Detector("C:\\Code\\Java\\FaceDetector\\lib\\haarcascade_frontalface_default.xml"); flickr.photoservice.flickrresponse.Rsp response = getFlickrPhotos(); for (Photo photo : response.getPhotos().getPhoto()) { String timestamp = String.valueOf(Calendar.getInstance().getTimeInMillis()); BufferedImage originalImage = getPhysicalFlickrImage(photo); if (originalImage != null) { File originalImageFile = new File( "C:\\Code\\Java\\FaceDetector\\images\\original\\" + timestamp + ".jpg"); //Sanselan.writeImage(originalImage, originalImageFile, ImageFormat.IMAGE_FORMAT_JPEG, null); ImageIO.write(originalImage, "JPG", originalImageFile); List<Rectangle> res = detector.getFaces(originalImageFile.getAbsolutePath(), 3, 1.25f, 0.1f, 1, false);/*from w w w .j av a 2 s .c o m*/ for (Rectangle face : res) { BufferedImage faceImage = originalImage.getSubimage(face.x, face.y, face.width, face.height); Sanselan.writeImage(faceImage, new File("C:\\Code\\Java\\FaceDetector\\images\\" + String.valueOf(Calendar.getInstance().getTimeInMillis()) + ".png"), ImageFormat.IMAGE_FORMAT_PNG, null); } } } }
From source file:com.clank.launcher.Launcher.java
/** * Bootstrap.// www . j a va 2 s. co m * * @param args args */ public static void main(String[] args) { SimpleLogFormatter.configureGlobalLogger(); LauncherArguments options = new LauncherArguments(); try { new JCommander(options, args); } catch (ParameterException e) { System.err.print(e.getMessage()); System.exit(1); return; } Integer bsVersion = options.getBootstrapVersion(); log.info(bsVersion != null ? "Bootstrap version " + bsVersion + " detected" : "Not bootstrapped"); File dir = options.getDir(); if (dir != null) { log.info("Using given base directory " + dir.getAbsolutePath()); } else { dir = new File("."); log.info("Using current directory " + dir.getAbsolutePath()); } final File baseDir = dir; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder()); Launcher launcher = new Launcher(baseDir); new LauncherFrame(launcher).setVisible(true); } catch (Throwable t) { log.log(Level.WARNING, "Load failure", t); SwingHelper.showErrorDialog(null, "Uh oh! The updater couldn't be opened because a " + "problem was encountered.", "Launcher error", t); } } }); }