Package com.google.common.io

Examples of com.google.common.io.Closer.register()


    closer.register(eventStream);
    closer.register(w);
    try {
      OutputStream sysout = closer.register(new BufferedOutputStream(new FileOutputStream(sysoutFile)));
      OutputStream syserr = closer.register(new BufferedOutputStream(new FileOutputStream(syserrFile)));
      RandomAccessFile streamsBuffer = closer.register(new RandomAccessFile(streamsBufferFile, "rw"));

      Execute execute = forkProcess(slave, eventBus, commandline, eventStream, sysout, syserr, streamsBuffer);
      log("Forked JVM J" + slave.id + " finished with exit code: " + execute.getExitValue(), Project.MSG_DEBUG);

      if (execute.isFailure()) {
View Full Code Here


   */
  private File createTemporaryAntFile(Document doc) throws IOException {
    Closer closer = Closer.create();
    try {
      File antFile = File.createTempFile("junit4-ant-", ".xml", dir);
      OutputStream os = closer.register(new FileOutputStream(antFile));
      XMLWriter xmlWriter = new XMLWriter(os, OutputFormat.createPrettyPrint());
      xmlWriter.write(doc);
      return antFile;
    } catch (Throwable t) {
      throw closer.rethrow(t);
View Full Code Here

    private void sendMessage(String ircCatHost, int ircCatPort, String message, String channel) throws IOException {
        Socket socket = new Socket(ircCatHost, ircCatPort);
        Closer closer = Closer.create();
        try {
            Writer out = closer.register(new OutputStreamWriter(socket.getOutputStream()));
            out.write(format("%s %s\n", channel, message));
            out.flush();
        } catch (IOException e) {
            socket.close();
            throw closer.rethrow(e);
View Full Code Here

                        }
                        while (!shutdown) {
                            Socket socket = serverSocket.accept();
                            Closer closer = Closer.create();
                            try {
                                BufferedReader in = closer.register(new BufferedReader(new InputStreamReader(socket.getInputStream())));
                                String message = in.readLine();
                                messages.add(message);
                                synchronized (this) {
                                    this.notifyAll();
                                }
View Full Code Here

    } catch (KeyStoreException e) {
      throw new RuntimeException("no provider exists for the keystore type " + type, e);
    }

    Closer closer = Closer.create();
    InputStream stream = closer.register(new BufferedInputStream(new FileInputStream(keyStoreFile)));
    try {
      keyStore.load(stream, (password == null) ? null : password.toCharArray());
    } catch (CertificateException e) {
      throw new RuntimeException("some certificates could not be loaded", e);
    } catch (NoSuchAlgorithmException e) {
View Full Code Here

                LOGGER.debug("writing {} metrics to file {}", metrics.size(), file);
                OutputStream fileOut = new FileOutputStream(file, true);
                if (compress) {
                    fileOut = new GZIPOutputStream(fileOut);
                }
                out = closer.register(new OutputStreamWriter(fileOut, "UTF-8"));
                for (Metric m : metrics) {
                    out.append(m.getConfig().getName()).append('\t')
                       .append(m.getConfig().getTags().toString()).append('\t')
                       .append(m.getValue().toString()).append('\n');
                }
View Full Code Here

    public void processFile(File input, File output) throws IOException {

        Closer closer = Closer.create();
        try {

            InputStream fis = closer.register(new FileInputStream(input));
            OutputStream fos = closer.register(new BufferedOutputStream(new FileOutputStream(output)));

            log.debug("Processing file " + input);
            log.debug("Output file " + output);
View Full Code Here

        Closer closer = Closer.create();
        try {

            InputStream fis = closer.register(new FileInputStream(input));
            OutputStream fos = closer.register(new BufferedOutputStream(new FileOutputStream(output)));

            log.debug("Processing file " + input);
            log.debug("Output file " + output);

            processStream(fis, fos);
View Full Code Here

        Container container = new Container(artifactFile.getName());

        try
        {
            ZipInputStream zis =
                    closer.register(new ZipInputStream(new BufferedInputStream(new FileInputStream(artifactFile))));

            getLog().info("Extracting " + artifactFile + " to " + targetWork);
            ZipFileIteratorAndExtractor iterator = new ZipFileIteratorAndExtractor(container, zis, targetWork);
            iterator.extract();
View Full Code Here

            TemplateProcessor processor = new TemplateProcessor(properties, tokenStart, tokenEnd, getLog());
            FileTemplating.processFiles(getLog(), targetWork, processor);

            getLog().info("Compressing to " + finalFile);
            ZipOutputStream zos =
                    closer.register(new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(finalFile))));
            ZipFileCompressor compressor = new ZipFileCompressor(container, zos, targetWork);
            compressor.compress(getLog());

            getLog().info("Done.");
        } catch (IOException e)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.