Package org.apache.commons.io.output

Examples of org.apache.commons.io.output.CloseShieldOutputStream


    super.initialize(context);

    try {
      if (out == null) {
        if ("-".equals(outputFile.getName())) {
          out = new PrintWriter(new CloseShieldOutputStream(System.out));
        } else {
          if (outputFile.getParentFile() != null) {
            outputFile.getParentFile().mkdirs();
          }
          out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"));
View Full Code Here


        switch (a.getPreferredAccess()) {
            case NONE:
                throw new RepositoryException("Artifact has no content.");

            case SPOOL:
                OutputStream nout = new CloseShieldOutputStream(jOut);
                a.spool(nout);
                break;

            case STREAM:
                nout = new CloseShieldOutputStream(jOut);
                InputStream in = a.getInputStream();
                IOUtils.copy(in, nout);
                in.close();
                break;
        }
View Full Code Here

    public void writeFile(InputStream in, String relPath) throws IOException {
        ZipEntry e = new ZipEntry(relPath);
        exportInfo.update(ExportInfo.Type.ADD, e.getName());
        jOut.putNextEntry(e);
        OutputStream nout = new CloseShieldOutputStream(jOut);
        IOUtils.copy(in, nout);
        in.close();
        jOut.closeEntry();
    }
View Full Code Here

     * Streams the encoded binary data
     */
    public void streamTo(OutputStream os) throws IOException {
       
        //we need to create a safe output stream that cannot be closed
        final OutputStream safeOutputStream = new CloseShieldOutputStream(os);

        //get the encoder
        final FilterOutputStream fos = getBinaryValueType().getEncoder(safeOutputStream);

        //stream with the encoder
View Full Code Here

    @Override
    public void streamBinaryTo(OutputStream os) throws IOException {
       
        //we need to create a safe output stream that cannot be closed
        final OutputStream safeOutputStream = new CloseShieldOutputStream(os);
       
        //get the decoder
        final FilterOutputStream fos = getBinaryValueType().getDecoder(safeOutputStream);
       
        //write with the decoder
View Full Code Here

                // Multiple repositories: ok to use public repo since only non-repository-specific things are needed
                resultsNode.add(writer.toJson(entity, entityList.getWriteOptions(),
                        repositoryMgr.getDefaultRepository()));
            }

            JsonFormat.serialize(listNode, new CloseShieldOutputStream(entityStream));
        } catch (Throwable e) {
            // We catch every throwable, since otherwise no one does it and we will not have any trace
            // of Errors that happened.
            throw new ResourceException("Error serializing entity list.", e, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
        }
View Full Code Here

    public void writeTo(Blob blob, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
            throws IOException, WebApplicationException {

        try {
            JsonFormat.serialize(BlobConverter.toJson(blob), new CloseShieldOutputStream(entityStream));
        } catch (Throwable e) {
            // We catch every throwable, since otherwise no one does it and we will not have any trace
            // of Errors that happened.
            throw new ResourceException("Error serializing entity.", e, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
        }
View Full Code Here

        try {
            EntityWriter writer = EntityRegistry.findWriter(object.getEntity().getClass());
            // Multiple repositories: ok to use public repo since only non-repository-specific things are needed
            ObjectNode json = writer.toJson(object.getEntity(), object.getWriteOptions(),
                    repositoryMgr.getDefaultRepository());
            JsonFormat.serialize(json, new CloseShieldOutputStream(entityStream));
        } catch (Throwable e) {
            // We catch every throwable, since otherwise no one does it and we will not have any trace
            // of Errors that happened.
            throw new ResourceException("Error serializing entity.", e,
                    Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
View Full Code Here

          + "; claimedLen=" + claimedLen);
      WritableUtils.writeVLong(out, curEntryId);
      WritableUtils.writeVLong(out, claimedLen);
      this.curClaimedLen = claimedLen;
      this.userCountingOutputStream = new CountingOutputStream(
          new CloseShieldOutputStream(out));
      if (null == this.codec) {
        // No codec; pass thru the same OutputStream to the user.
        this.userOutputStream = this.userCountingOutputStream;
      } else {
        // Wrap our CountingOutputStream in a compressing OutputStream to
View Full Code Here

import java.io.OutputStream;

public class SafeStreams {

    public static OutputStream systemErr() {
        return new CloseShieldOutputStream(System.err);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.output.CloseShieldOutputStream

Copyright © 2018 www.massapicom. 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.