当前位置: 首页>>代码示例>>Java>>正文


Java BufferedOutputStream类代码示例

本文整理汇总了Java中java.io.BufferedOutputStream的典型用法代码示例。如果您正苦于以下问题:Java BufferedOutputStream类的具体用法?Java BufferedOutputStream怎么用?Java BufferedOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BufferedOutputStream类属于java.io包,在下文中一共展示了BufferedOutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: download

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * Perform the specified SSH file download.
 * 
 * @param from source remote file URI ({@code ssh} protocol)
 * @param to target local folder URI ({@code file} protocol)
 */
private static void download(URI from, URI to) {
    File out = new File(new File(to), getName(from.getPath()));
    try (SessionHolder<ChannelSftp> session = new SessionHolder<>(ChannelType.SFTP, from);
            OutputStream os = new FileOutputStream(out);
            BufferedOutputStream bos = new BufferedOutputStream(os)) {

        LOG.info("Downloading {} --> {}", session.getMaskedUri(), to);
        ChannelSftp channel = session.getChannel();
        channel.connect();
        channel.cd(getFullPath(from.getPath()));
        channel.get(getName(from.getPath()), bos);

    } catch (Exception e) {
        throw new RemoteFileDownloadFailedException("Cannot download file", e);
    }
}
 
开发者ID:Nordstrom,项目名称:Remote-Session,代码行数:23,代码来源:SshUtils.java

示例2: downloadFile

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * 从FTP服务器下载指定的文件至本地
 * 
 * @author gaoxianglong
 */
public boolean downloadFile(File file) {
	boolean result = false;
	FTPClient ftpClient = ftpConnManager.getFTPClient();
	if (null == ftpClient || !ftpClient.isConnected()) {
		return result;
	}
	try (BufferedOutputStream out = new BufferedOutputStream(
			new FileOutputStream(System.getProperty("user.home") + "/" + file.getName()))) {
		result = ftpClient.retrieveFile(file.getName(), out);
		if (result) {
			result = true;
			log.info("file-->" + file.getPath() + "成功从FTP服务器下载");
		}
	} catch (Exception e) {
		log.error("error", e);
	} finally {
		disconnect(ftpClient);
	}
	return result;
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:26,代码来源:FtpUtils.java

示例3: save

import java.io.BufferedOutputStream; //导入依赖的package包/类
public boolean save(String imageUri, Bitmap bitmap) throws IOException {
    boolean z = false;
    Editor editor = this.cache.edit(getKey(imageUri));
    if (editor != null) {
        OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), this.bufferSize);
        z = false;
        try {
            z = bitmap.compress(this.compressFormat, this.compressQuality, os);
            if (z) {
                editor.commit();
            } else {
                editor.abort();
            }
        } finally {
            IoUtils.closeSilently(os);
        }
    }
    return z;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:LruDiscCache.java

示例4: openLog

import java.io.BufferedOutputStream; //导入依赖的package包/类
void openLog(final String loggingFolder) {
    try {
        filename = loggingFolder + "/ProcessingTime_" + filterClassName
                + DATE_FORMAT.format(new Date()) + ".txt";
        logStream = new PrintStream(new BufferedOutputStream(
                new FileOutputStream(new File(filename))));
        log.log(Level.INFO, "Created motion flow logging file with "
                + "processing time statistics at {0}", filename);
        logStream.println("Processing time statistics of motion flow "
                + "calculation, averaged over event packets.");
        logStream.println("Date: " + new Date());
        logStream.println("Filter used: " + filterClassName);
        logStream.println();
        logStream.println("timestamp [us] | processing time [us]");
    } catch (FileNotFoundException ex) {
        log.log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:19,代码来源:MotionFlowStatistics.java

示例5: startConnection

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * Starts the WebSocket connection
 *
 * @throws IOException
 */
private void startConnection() throws IOException {
    bos = new BufferedOutputStream(socket.getOutputStream(), 65536);

    byte[] key = new byte[16];
    Random random = new Random();
    random.nextBytes(key);
    String base64Key = Base64.encodeBase64String(key);

    byte[] handshake = createHandshake(base64Key);
    bos.write(handshake);
    bos.flush();

    InputStream inputStream = socket.getInputStream();
    verifyServerHandshake(inputStream, base64Key);

    writerThread.start();

    notifyOnOpen();

    bis = new BufferedInputStream(socket.getInputStream(), 65536);
    read();
}
 
开发者ID:gusavila92,项目名称:java-android-websocket-client,代码行数:28,代码来源:WebSocketClient.java

示例6: openJarOutputStream

import java.io.BufferedOutputStream; //导入依赖的package包/类
private ZipOutputStream openJarOutputStream(File outputJar) {
    try {
        ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outputJar), BUFFER_SIZE));
        outputStream.setLevel(0);
        return outputStream;
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:RuntimeShadedJarCreator.java

示例7: downloadZip

import java.io.BufferedOutputStream; //导入依赖的package包/类
private void downloadZip(String link) throws MalformedURLException, IOException
{
	URL url = new URL(link);
	URLConnection conn = url.openConnection();
	InputStream is = conn.getInputStream();
	long max = conn.getContentLength();
	gui.setOutputText("Downloding file...");
	BufferedOutputStream fOut = new BufferedOutputStream(new FileOutputStream(new File("update.zip")));
	byte[] buffer = new byte[32 * 1024];
	int bytesRead = 0;
	int in = 0;
	while ((bytesRead = is.read(buffer)) != -1) {
		in += bytesRead;
		fOut.write(buffer, 0, bytesRead);
	}
	fOut.flush();
	fOut.close();
	is.close();
	gui.setOutputText("Download Complete!");

}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:22,代码来源:Downloader.java

示例8: serialize

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * serialize the datatree and session into the file snapshot
 * @param dt the datatree to be serialized
 * @param sessions the sessions to be serialized
 * @param snapShot the file to store snapshot into
 */
public synchronized void serialize(DataTree dt, Map<Long, Integer> sessions, File snapShot)
        throws IOException {
    if (!close) {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt,sessions,oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:FileSnap.java

示例9: serialize

import java.io.BufferedOutputStream; //导入依赖的package包/类
private void serialize(T newValue) {
    try {
        if (!cacheFile.isFile()) {
            cacheFile.createNewFile();
        }
        chmod.chmod(cacheFile.getParentFile(), 0700); // read-write-execute for user only
        chmod.chmod(cacheFile, 0600); // read-write for user only
        OutputStreamBackedEncoder encoder = new OutputStreamBackedEncoder(new BufferedOutputStream(new FileOutputStream(cacheFile)));
        try {
            serializer.write(encoder, newValue);
        } finally {
            encoder.close();
        }
    } catch (Exception e) {
        throw new GradleException(String.format("Could not write cache value to '%s'.", cacheFile), e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:SimpleStateCache.java

示例10: FileLogger

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * Constructs a new file logger from the given annotated formula.
 * 
 * @ensures this.formula' = annotated.node
 * @ensures this.originalFormula' = annotated.source[annotated.node]
 * @ensures this.bounds' = bounds
 * @ensures this.log().roots() = Nodes.conjuncts(annotated)
 * @ensures no this.records'
 */
FileLogger(final AnnotatedNode<Formula> annotated, Bounds bounds) {
	this.annotated = annotated;
	try {
		this.file = File.createTempFile("kodkod", ".log");
		this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
	} catch (IOException e1) {
		throw new RuntimeException(e1);
	}

	final Map<Formula,Set<Variable>> freeVarMap = freeVars(annotated);
	final Variable[] empty = new Variable[0];

	this.logMap = new FixedMap<Formula,Variable[]>(freeVarMap.keySet());

	for (Map.Entry<Formula,Variable[]> e : logMap.entrySet()) {
		Set<Variable> vars = freeVarMap.get(e.getKey());
		int size = vars.size();
		if (size == 0) {
			e.setValue(empty);
		} else {
			e.setValue(Containers.identitySort(vars.toArray(new Variable[size])));
		}
	}
	this.bounds = bounds.unmodifiableView();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:35,代码来源:FileLogger.java

示例11: save

import java.io.BufferedOutputStream; //导入依赖的package包/类
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
	File imageFile = getFile(imageUri);
	File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX);
	boolean loaded = false;
	try {
		OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize);
		try {
			loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize);
		} finally {
			IoUtils.closeSilently(os);
		}
	} finally {
		if (loaded && !tmpFile.renameTo(imageFile)) {
			loaded = false;
		}
		if (!loaded) {
			tmpFile.delete();
		}
	}
	return loaded;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BaseDiskCache.java

示例12: getContentOutputStream

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * @see Channels#newOutputStream(java.nio.channels.WritableByteChannel)
 */
public OutputStream getContentOutputStream() throws ContentIOException
{
    try
    {
        WritableByteChannel channel = getWritableChannel();
        OutputStream is = new BufferedOutputStream(Channels.newOutputStream(channel));
        // done
        return is;
    }
    catch (Throwable e)
    {
        throw new ContentIOException("Failed to open stream onto channel: \n" +
                "   writer: " + this,
                e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AbstractContentWriter.java

示例13: writeMeasurementDataToFile

import java.io.BufferedOutputStream; //导入依赖的package包/类
/**
 * Write all taken data to a csv file at the desired place.
 * @param outFile output file that should be used to store data
 */
public void writeMeasurementDataToFile(final File outFile){
    try(
        final BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outFile))
    ){
        //print head row for data
        outputStream.write(csvifyStringList(generateHeadForCsv()).getBytes());
        outputStream.flush();
        //print actual collected data
        for(Measurement mt: this.data){
            outputStream.write(csvifyStringList(mt.getStringListFromMeasurement()).getBytes());
            outputStream.flush();
        }
    } catch (IOException e) {
        log.log(Level.WARNING,"IO Exception writing measurement data to disc",e);
    }
}
 
开发者ID:deB4SH,项目名称:Byter,代码行数:21,代码来源:PerformanceTimer.java

示例14: main

import java.io.BufferedOutputStream; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    // Handle command line arguments
    if (args.length != 2) {
        System.err.println("Usage: java AdaptiveHuffmanCompress InputFile OutputFile");
        System.exit(1);
        return;
    }
    File inputFile = new File(args[0]);
    File outputFile = new File(args[1]);

    // Perform file compression
    InputStream in = new BufferedInputStream(new FileInputStream(inputFile));
    BitOutputStream out = new BitOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
    try {
        compress(in, out);
    } finally {
        out.close();
        in.close();
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:21,代码来源:AdaptiveHuffmanCompress.java

示例15: prepare

import java.io.BufferedOutputStream; //导入依赖的package包/类
private void prepare(File bundleFile, File exploderDir, boolean hasInnerJar) {
    getLogger().info("prepare bundle " + bundleFile.getAbsolutePath());

    if (exploderDir.exists()) {
        return;
    }

    LibraryCache.unzipAar(bundleFile, exploderDir, getProject());
    if (hasInnerJar) {
        // verify the we have a classes.jar, if we don't just create an empty one.
        File classesJar = new File(new File(exploderDir, "jars"), "classes.jar");
        if (classesJar.exists()) {
            return;
        }
        try {
            Files.createParentDirs(classesJar);
            JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(
                classesJar)), new Manifest());
            jarOutputStream.close();
        } catch (IOException e) {
            throw new RuntimeException("Cannot create missing classes.jar", e);
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:PrepareAwoBundleTask.java


注:本文中的java.io.BufferedOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。