org.apache.cxf.io.CachedOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cxf-bundle-jaxrs Show documentation
Show all versions of cxf-bundle-jaxrs Show documentation
Apache CXF JAX-RS Bundle Jar
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.io;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.cxf.helpers.FileUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
public class CachedOutputStream extends OutputStream {
private static final File DEFAULT_TEMP_DIR;
private static final int DEFAULT_THRESHOLD;
static {
String s = System.getProperty("org.apache.cxf.io.CachedOutputStream.Threshold",
"-1");
int i = Integer.parseInt(s);
if (i <= 0) {
i = 64 * 1024;
}
DEFAULT_THRESHOLD = i;
s = System.getProperty("org.apache.cxf.io.CachedOutputStream.OutputDirectory");
if (s != null) {
File f = new File(s);
if (f.exists() && f.isDirectory()) {
DEFAULT_TEMP_DIR = f;
} else {
DEFAULT_TEMP_DIR = null;
}
} else {
DEFAULT_TEMP_DIR = null;
}
}
protected boolean outputLocked;
protected OutputStream currentStream;
private long threshold = DEFAULT_THRESHOLD;
private int totalLength;
private boolean inmem;
private boolean tempFileFailed;
private File tempFile;
private File outputDir = DEFAULT_TEMP_DIR;
private boolean allowDeleteOfFile = true;
private List callbacks;
private List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy