List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:com.linkedin.pinotdruidbenchmark.DruidThroughput.java
@SuppressWarnings("InfiniteLoopStatement") public static void main(String[] args) throws Exception { if (args.length != 3 && args.length != 4) { System.err.println(/*from w ww . jav a 2s. com*/ "3 or 4 arguments required: QUERY_DIR, RESOURCE_URL, NUM_CLIENTS, TEST_TIME (seconds)."); return; } File queryDir = new File(args[0]); String resourceUrl = args[1]; final int numClients = Integer.parseInt(args[2]); final long endTime; if (args.length == 3) { endTime = Long.MAX_VALUE; } else { endTime = System.currentTimeMillis() + Integer.parseInt(args[3]) * MILLIS_PER_SECOND; } File[] queryFiles = queryDir.listFiles(); assert queryFiles != null; Arrays.sort(queryFiles); final int numQueries = queryFiles.length; final HttpPost[] httpPosts = new HttpPost[numQueries]; for (int i = 0; i < numQueries; i++) { HttpPost httpPost = new HttpPost(resourceUrl); httpPost.addHeader("content-type", "application/json"); StringBuilder stringBuilder = new StringBuilder(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(queryFiles[i]))) { int length; while ((length = bufferedReader.read(CHAR_BUFFER)) > 0) { stringBuilder.append(new String(CHAR_BUFFER, 0, length)); } } String query = stringBuilder.toString(); httpPost.setEntity(new StringEntity(query)); httpPosts[i] = httpPost; } final AtomicInteger counter = new AtomicInteger(0); final AtomicLong totalResponseTime = new AtomicLong(0L); final ExecutorService executorService = Executors.newFixedThreadPool(numClients); for (int i = 0; i < numClients; i++) { executorService.submit(new Runnable() { @Override public void run() { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { while (System.currentTimeMillis() < endTime) { long startTime = System.currentTimeMillis(); CloseableHttpResponse httpResponse = httpClient .execute(httpPosts[RANDOM.nextInt(numQueries)]); httpResponse.close(); long responseTime = System.currentTimeMillis() - startTime; counter.getAndIncrement(); totalResponseTime.getAndAdd(responseTime); } } catch (IOException e) { e.printStackTrace(); } } }); } executorService.shutdown(); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() < endTime) { Thread.sleep(REPORT_INTERVAL_MILLIS); double timePassedSeconds = ((double) (System.currentTimeMillis() - startTime)) / MILLIS_PER_SECOND; int count = counter.get(); double avgResponseTime = ((double) totalResponseTime.get()) / count; System.out.println("Time Passed: " + timePassedSeconds + "s, Query Executed: " + count + ", QPS: " + count / timePassedSeconds + ", Avg Response Time: " + avgResponseTime + "ms"); } }
From source file:edu.illinois.cs.cogcomp.datalessclassification.ta.ESADatalessAnnotator.java
/** * @param args config: config file path testFile: Test File *//*from www .j a va2s. c o m*/ public static void main(String[] args) { CommandLine cmd = getCMDOpts(args); ResourceManager rm; try { String configFile = cmd.getOptionValue("config", "config/project.properties"); ResourceManager nonDefaultRm = new ResourceManager(configFile); rm = new ESADatalessConfigurator().getConfig(nonDefaultRm); } catch (IOException e) { rm = new ESADatalessConfigurator().getDefaultConfig(); } String testFile = cmd.getOptionValue("testFile", "data/graphicsTestDocument.txt"); StringBuilder sb = new StringBuilder(); String line; try (BufferedReader br = new BufferedReader(new FileReader(new File(testFile)))) { while ((line = br.readLine()) != null) { sb.append(line); sb.append(" "); } String text = sb.toString().trim(); TokenizerTextAnnotationBuilder taBuilder = new TokenizerTextAnnotationBuilder(new StatefulTokenizer()); TextAnnotation ta = taBuilder.createTextAnnotation(text); ESADatalessAnnotator datalessAnnotator = new ESADatalessAnnotator(rm); datalessAnnotator.addView(ta); List<Constituent> annots = ta.getView(ViewNames.DATALESS_ESA).getConstituents(); System.out.println("Predicted LabelIDs:"); for (Constituent annot : annots) { System.out.println(annot.getLabel()); } Map<String, String> labelNameMap = DatalessAnnotatorUtils .getLabelNameMap(rm.getString(DatalessConfigurator.LabelName_Path.key)); System.out.println("Predicted Labels:"); for (Constituent annot : annots) { System.out.println(labelNameMap.get(annot.getLabel())); } } catch (FileNotFoundException e) { e.printStackTrace(); logger.error("Test File not found at " + testFile + " ... exiting"); System.exit(-1); } catch (IOException e) { e.printStackTrace(); logger.error("IO Error while reading the test file ... exiting"); System.exit(-1); } catch (AnnotatorException e) { e.printStackTrace(); logger.error("Error Annotating the Test Document with the Dataless View ... exiting"); System.exit(-1); } }
From source file:com.nextdoor.bender.ValidateSchema.java
public static void main(String[] args) throws ParseException, InterruptedException, IOException { /*//from w w w . j a v a2 s.c o m * Parse cli arguments */ Options options = new Options(); options.addOption(Option.builder().longOpt("schema").hasArg() .desc("Filename to output schema to. Default: schema.json").build()); options.addOption(Option.builder().longOpt("configs").hasArgs() .desc("List of config files to validate against schema.").build()); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); String schemaFilename = cmd.getOptionValue("schema", "schema.json"); String[] configFilenames = cmd.getOptionValues("configs"); /* * Validate config files against schema */ boolean hasFailures = false; for (String configFilename : configFilenames) { StringBuilder sb = new StringBuilder(); Files.lines(Paths.get(configFilename), StandardCharsets.UTF_8).forEach(p -> sb.append(p + "\n")); System.out.println("Attempting to validate " + configFilename); try { ObjectMapper mapper = BenderConfig.getObjectMapper(configFilename); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); BenderConfig.load(configFilename, sb.toString(), mapper, true); System.out.println("Valid"); BenderConfig config = BenderConfig.load(configFilename, sb.toString()); } catch (ConfigurationException e) { System.out.println("Invalid"); e.printStackTrace(); hasFailures = true; } } if (hasFailures) { System.exit(1); } }
From source file:de.tudarmstadt.ukp.csniper.resbuild.EvaluationItemFixer2.java
public static void main(String[] args) { connect(HOST, DATABASE, USER, PASSWORD); Map<Integer, String> items = new HashMap<Integer, String>(); Map<Integer, String> failed = new HashMap<Integer, String>(); // fetch coveredTexts of dubious items and clean it PreparedStatement select = null; PreparedStatement update = null; try {/*from w ww . j a va 2s . c om*/ StringBuilder selectQuery = new StringBuilder(); selectQuery.append("SELECT * FROM cachedparse WHERE pennTree = 'ERROR' OR pennTree = ''"); select = connection.prepareStatement(selectQuery.toString()); log.info("Running query [" + selectQuery.toString() + "]."); ResultSet rs = select.executeQuery(); // CSVWriter writer; String text; JCas jcas = JCasFactory.createJCas(); String updateQuery = "UPDATE CachedParse SET pennTree = ? WHERE collectionId = ? AND documentId = ? AND beginOffset = ? AND endOffset = ?"; update = connection.prepareStatement(updateQuery); // File base = new File(""); AnalysisEngine sentences = createEngine(DummySentenceSplitter.class); AnalysisEngine tokenizer = createEngine(StanfordSegmenter.class, StanfordSegmenter.PARAM_CREATE_SENTENCES, false, StanfordSegmenter.PARAM_CREATE_TOKENS, true); AnalysisEngine parser = createEngine(StanfordParser.class, StanfordParser.PARAM_WRITE_CONSTITUENT, true, // StanfordParser.PARAM_CREATE_DEPENDENCY_TAGS, true, StanfordParser.PARAM_WRITE_PENN_TREE, true, StanfordParser.PARAM_LANGUAGE, "en", StanfordParser.PARAM_VARIANT, "factored"); while (rs.next()) { String collectionId = rs.getString("collectionId"); String documentId = rs.getString("documentId"); int beginOffset = rs.getInt("beginOffset"); int endOffset = rs.getInt("endOffset"); text = retrieveCoveredText(collectionId, documentId, beginOffset, endOffset); jcas.setDocumentText(text); jcas.setDocumentLanguage("en"); sentences.process(jcas); tokenizer.process(jcas); parser.process(jcas); // writer = new CSVWriter(new FileWriter(new File(base, documentId + ".csv")); System.out.println("Updating " + text); for (PennTree p : JCasUtil.select(jcas, PennTree.class)) { String tree = StringUtils.normalizeSpace(p.getPennTree()); update.setString(1, tree); update.setString(2, collectionId); update.setString(3, documentId); update.setInt(4, beginOffset); update.setInt(5, endOffset); update.executeUpdate(); System.out.println("with tree " + tree); break; } jcas.reset(); } } catch (SQLException e) { log.error("Exception while selecting: " + e.getMessage()); } catch (UIMAException e) { e.printStackTrace(); } finally { closeQuietly(select); closeQuietly(update); } // write logs // BufferedWriter bwf = null; // BufferedWriter bws = null; // try { // bwf = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File( // LOG_FAILED)), "UTF-8")); // for (Entry<Integer, String> e : failed.entrySet()) { // bwf.write(e.getKey() + " - " + e.getValue() + "\n"); // } // // bws = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File( // LOG_SUCCESSFUL)), "UTF-8")); // for (Entry<Integer, String> e : items.entrySet()) { // bws.write(e.getKey() + " - " + e.getValue() + "\n"); // } // } // catch (IOException e) { // log.error("Got an IOException while writing the log files."); // } // finally { // IOUtils.closeQuietly(bwf); // IOUtils.closeQuietly(bws); // } log.info("Texts for [" + items.size() + "] items need to be cleaned up."); // update the dubious items with the cleaned coveredText // PreparedStatement update = null; // try { // String updateQuery = "UPDATE EvaluationItem SET coveredText = ? WHERE id = ?"; // // update = connection.prepareStatement(updateQuery); // int i = 0; // for (Entry<Integer, String> e : items.entrySet()) { // int id = e.getKey(); // String coveredText = e.getValue(); // // // update item in database // update.setString(1, coveredText); // update.setInt(2, id); // update.executeUpdate(); // log.debug("Updating " + id + " with [" + coveredText + "]"); // // // show percentage of updated items // i++; // int part = (int) Math.ceil((double) items.size() / 100); // if (i % part == 0) { // log.info(i / part + "% finished (" + i + "/" + items.size() + ")."); // } // } // } // catch (SQLException e) { // log.error("Exception while updating: " + e.getMessage()); // } // finally { // closeQuietly(update); // } closeQuietly(connection); }
From source file:net.sfr.tv.mom.mgt.HornetqConsole.java
/** * @param args the command line arguments *//*from w w w. j a v a 2 s . co m*/ public static void main(String[] args) { try { String jmxHost = "127.0.0.1"; String jmxPort = "6001"; // Process command line arguments String arg; for (int i = 0; i < args.length; i++) { arg = args[i]; switch (arg) { case "-h": jmxHost = args[++i]; break; case "-p": jmxPort = args[++i]; break; default: break; } } // Check for arguments consistency if (StringUtils.isEmpty(jmxHost) || !NumberUtils.isNumber(jmxPort)) { LOGGER.info("Usage : "); LOGGER.info("hq-console.jar <-h host(127.0.0.1)> <-p port(6001)>\n"); System.exit(1); } System.out.println( SystemUtils.LINE_SEPARATOR.concat(Ansi.format("HornetQ Console ".concat(VERSION), Color.CYAN))); final StringBuilder _url = new StringBuilder("service:jmx:rmi://").append(jmxHost).append(':') .append(jmxPort).append("/jndi/rmi://").append(jmxHost).append(':').append(jmxPort) .append("/jmxrmi"); final String jmxServiceUrl = _url.toString(); JMXConnector jmxc = null; final CommandRouter router = new CommandRouter(); try { jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null); assert jmxc != null; // jmxc must be not null } catch (final MalformedURLException e) { System.out.println(SystemUtils.LINE_SEPARATOR .concat(Ansi.format(jmxServiceUrl + " :" + e.getMessage(), Color.RED))); } catch (Throwable t) { System.out.println(SystemUtils.LINE_SEPARATOR.concat( Ansi.format("Unable to connect to JMX service URL : ".concat(jmxServiceUrl), Color.RED))); System.out.print(SystemUtils.LINE_SEPARATOR.concat( Ansi.format("Did you add jmx-staticport-agent.jar to your classpath ?", Color.MAGENTA))); System.out.println(SystemUtils.LINE_SEPARATOR.concat(Ansi.format( "Or did you set the com.sun.management.jmxremote.port option in the hornetq server startup script ?", Color.MAGENTA))); System.exit(-1); } System.out.println("\n".concat(Ansi .format("Successfully connected to JMX service URL : ".concat(jmxServiceUrl), Color.YELLOW))); final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); // PRINT SERVER STATUS REPORT System.out.print((String) router.get(Command.STATUS, Option.VM).execute(mbsc, null)); System.out.print((String) router.get(Command.STATUS, Option.SERVER).execute(mbsc, null)); System.out.print((String) router.get(Command.STATUS, Option.CLUSTER).execute(mbsc, null)); printHelp(router); // START COMMAND LINE Scanner scanner = new Scanner(System.in); System.out.print("> "); String input; while (!(input = scanner.nextLine().concat(" ")).equals("exit ")) { String[] cliArgs = input.split("\\ "); CommandHandler handler; if (cliArgs.length < 1) { System.out.print("> "); continue; } Command cmd = Command.fromString(cliArgs[0]); if (cmd == null) { System.out.print(Ansi.format("Syntax error !", Color.RED).concat("\n")); cmd = Command.HELP; } switch (cmd) { case STATUS: case LIST: case DROP: Set<Option> options = router.get(cmd); for (Option opt : options) { if (cliArgs[1].equals(opt.toString())) { handler = router.get(cmd, opt); String[] cmdOpts = null; if (cliArgs.length > 2) { cmdOpts = new String[cliArgs.length - 2]; for (int i = 0; i < cmdOpts.length; i++) { cmdOpts[i] = cliArgs[2 + i]; } } Object result = handler.execute(mbsc, cmdOpts); if (result != null && String.class.isAssignableFrom(result.getClass())) { System.out.print((String) result); } System.out.print("> "); } } break; case FORK: // EXECUTE SYSTEM COMMAND ProcessBuilder pb = new ProcessBuilder(Arrays.copyOfRange(cliArgs, 1, cliArgs.length)); pb.inheritIO(); pb.start(); break; case HELP: printHelp(router); break; } } } catch (MalformedURLException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); } echo(SystemUtils.LINE_SEPARATOR.concat(Ansi.format("Bye!", Color.CYAN))); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Date nowDate = now.getTime(); long twoHoursByMillis = 2 * HOUR; long thirtyMinutesByMillis = 30 * MINUTE; Date twoHoursAndThirtyMinutesFromNow = new Date(twoHoursByMillis + thirtyMinutesByMillis); System.out.println(String.format("now %s and later %s", nowDate, twoHoursAndThirtyMinutesFromNow)); long ms = 10304004543l; StringBuilder text = new StringBuilder(""); if (ms > DAY) { text.append(ms / DAY).append(" days "); ms %= DAY;//from w w w. j ava 2 s .c om } if (ms > HOUR) { text.append(ms / HOUR).append(" hours "); ms %= HOUR; } if (ms > MINUTE) { text.append(ms / MINUTE).append(" minutes "); ms %= MINUTE; } if (ms > SECOND) { text.append(ms / SECOND).append(" seconds "); ms %= SECOND; } text.append(ms + " ms"); System.out.println(text.toString()); }
From source file:com.dianping.wed.cache.redis.util.TestDataUtil.java
public static void main(String[] args) { // ????/*ww w. j a v a2 s .co m*/ //&method=incr¶meterTypes=com.dianping.wed.cache.redis.dto.WeddingRedisKeyDTO¶meters={"category":"justtest","params":["1","2"]} List<String> opList = new ArrayList<String>(opAndKey.keySet()); for (int i = 0; i < 1000; i++) { int index = RandomUtils.nextInt(opList.size()); String op = opList.get(index); String key = opAndKey.get(op); StringBuilder result = new StringBuilder(); int params = buildTestUrl(result, op, key); String fileName = "/Users/Bob/Desktop/data/data-" + params + ".csv"; try { //kuka.txt //kuka.txt FileWriter writer = new FileWriter(fileName, true); writer.write(result.toString()); writer.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println("done"); }
From source file:com.linkedin.pinotdruidbenchmark.DruidResponseTime.java
public static void main(String[] args) throws Exception { if (args.length != 4 && args.length != 5) { System.err.println(/* ww w.jav a 2 s. c o m*/ "4 or 5 arguments required: QUERY_DIR, RESOURCE_URL, WARM_UP_ROUNDS, TEST_ROUNDS, RESULT_DIR (optional)."); return; } File queryDir = new File(args[0]); String resourceUrl = args[1]; int warmUpRounds = Integer.parseInt(args[2]); int testRounds = Integer.parseInt(args[3]); File resultDir; if (args.length == 4) { resultDir = null; } else { resultDir = new File(args[4]); if (!resultDir.exists()) { if (!resultDir.mkdirs()) { throw new RuntimeException("Failed to create result directory: " + resultDir); } } } File[] queryFiles = queryDir.listFiles(); assert queryFiles != null; Arrays.sort(queryFiles); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost(resourceUrl); httpPost.addHeader("content-type", "application/json"); for (File queryFile : queryFiles) { StringBuilder stringBuilder = new StringBuilder(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(queryFile))) { int length; while ((length = bufferedReader.read(CHAR_BUFFER)) > 0) { stringBuilder.append(new String(CHAR_BUFFER, 0, length)); } } String query = stringBuilder.toString(); httpPost.setEntity(new StringEntity(query)); System.out.println( "--------------------------------------------------------------------------------"); System.out.println("Running query: " + query); System.out.println( "--------------------------------------------------------------------------------"); // Warm-up Rounds System.out.println("Run " + warmUpRounds + " times to warm up..."); for (int i = 0; i < warmUpRounds; i++) { CloseableHttpResponse httpResponse = httpClient.execute(httpPost); httpResponse.close(); System.out.print('*'); } System.out.println(); // Test Rounds System.out.println("Run " + testRounds + " times to get response time statistics..."); long[] responseTimes = new long[testRounds]; long totalResponseTime = 0L; for (int i = 0; i < testRounds; i++) { long startTime = System.currentTimeMillis(); CloseableHttpResponse httpResponse = httpClient.execute(httpPost); httpResponse.close(); long responseTime = System.currentTimeMillis() - startTime; responseTimes[i] = responseTime; totalResponseTime += responseTime; System.out.print(responseTime + "ms "); } System.out.println(); // Store result. if (resultDir != null) { File resultFile = new File(resultDir, queryFile.getName() + ".result"); CloseableHttpResponse httpResponse = httpClient.execute(httpPost); try (BufferedInputStream bufferedInputStream = new BufferedInputStream( httpResponse.getEntity().getContent()); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resultFile))) { int length; while ((length = bufferedInputStream.read(BYTE_BUFFER)) > 0) { bufferedWriter.write(new String(BYTE_BUFFER, 0, length)); } } httpResponse.close(); } // Process response times. double averageResponseTime = (double) totalResponseTime / testRounds; double temp = 0; for (long responseTime : responseTimes) { temp += (responseTime - averageResponseTime) * (responseTime - averageResponseTime); } double standardDeviation = Math.sqrt(temp / testRounds); System.out.println("Average response time: " + averageResponseTime + "ms"); System.out.println("Standard deviation: " + standardDeviation); } } }
From source file:JALPTest.java
/** * The main method that gets called to test JALoP. * * @param args the command line arguments *///from w w w .java2 s .c om public static void main(String[] args) { Producer producer = null; try { Options options = createOptions(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); String pathToXML = null; String type = null; String input = null; String privateKeyPath = null; String publicKeyPath = null; String certPath = null; String socketPath = null; Boolean hasDigest = false; File file = null; ApplicationMetadataXML xml = null; if (cmd.hasOption("h")) { System.out.println(usage); return; } if (cmd.hasOption("a")) { pathToXML = cmd.getOptionValue("a"); } if (cmd.hasOption("t")) { type = cmd.getOptionValue("t"); } if (cmd.hasOption("p")) { file = new File(cmd.getOptionValue("p")); } if (cmd.hasOption("s")) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); String s; while ((s = in.readLine()) != null && s.length() != 0) { sb.append(s); sb.append("\n"); } input = sb.toString(); } if (cmd.hasOption("j")) { socketPath = cmd.getOptionValue("j"); } if (cmd.hasOption("k")) { privateKeyPath = cmd.getOptionValue("k"); } if (cmd.hasOption("b")) { publicKeyPath = cmd.getOptionValue("b"); } if (cmd.hasOption("c")) { certPath = cmd.getOptionValue("c"); } if (cmd.hasOption("d")) { hasDigest = true; } if (pathToXML != null) { xml = createXML(readXML(pathToXML)); } producer = createProducer(xml, socketPath, privateKeyPath, publicKeyPath, certPath, hasDigest); callSend(producer, type, input, file); } catch (IOException e) { if (producer != null) { System.out.println("Failed to open socket: " + producer.getSocketFile()); } else { System.out.println("Failed to create Producer"); } } catch (Exception e) { error(e.toString()); return; } }
From source file:at.spardat.xma.xdelta.JarPatcher.java
/** * Main method to make {@link #applyDelta(ZipFile, ZipFile, ZipArchiveOutputStream, BufferedReader)} available at * the command line.<br>/*w w w . j a va 2 s .co m*/ * usage JarPatcher source patch output * * @param args the arguments * @throws IOException Signals that an I/O exception has occurred. */ public static void main(String[] args) throws IOException { String patchName = null; String outputName = null; String sourceName = null; if (args.length == 0) { System.err.println("usage JarPatcher patch [output [source]]"); System.exit(1); } else { patchName = args[0]; if (args.length > 1) { outputName = args[1]; if (args.length > 2) { sourceName = args[2]; } } } ZipFile patch = new ZipFile(patchName); ZipArchiveEntry listEntry = patch.getEntry("META-INF/file.list"); if (listEntry == null) { System.err.println("Invalid patch - list entry 'META-INF/file.list' not found"); System.exit(2); } BufferedReader list = new BufferedReader(new InputStreamReader(patch.getInputStream(listEntry))); String next = list.readLine(); if (sourceName == null) { sourceName = next; } next = list.readLine(); if (outputName == null) { outputName = next; } int ignoreSourcePaths = Integer.parseInt(System.getProperty("patcher.ignoreSourcePathElements", "0")); int ignoreOutputPaths = Integer.parseInt(System.getProperty("patcher.ignoreOutputPathElements", "0")); Path sourcePath = Paths.get(sourceName); Path outputPath = Paths.get(outputName); if (ignoreOutputPaths >= outputPath.getNameCount()) { patch.close(); StringBuilder b = new StringBuilder().append("Not enough path elements to ignore in output (") .append(ignoreOutputPaths).append(" in ").append(outputName).append(")"); throw new IOException(b.toString()); } if (ignoreSourcePaths >= sourcePath.getNameCount()) { patch.close(); StringBuilder b = new StringBuilder().append("Not enough path elements to ignore in source (") .append(sourcePath).append(" in ").append(sourceName).append(")"); throw new IOException(b.toString()); } sourcePath = sourcePath.subpath(ignoreSourcePaths, sourcePath.getNameCount()); outputPath = outputPath.subpath(ignoreOutputPaths, outputPath.getNameCount()); File sourceFile = sourcePath.toFile(); File outputFile = outputPath.toFile(); if (!(outputFile.getAbsoluteFile().getParentFile().mkdirs() || outputFile.getAbsoluteFile().getParentFile().exists())) { patch.close(); throw new IOException("Failed to create " + outputFile.getAbsolutePath()); } new JarPatcher(patchName, sourceFile.getName()).applyDelta(patch, new ZipFile(sourceFile), new ZipArchiveOutputStream(new FileOutputStream(outputFile)), list); list.close(); }