本文整理了Java中java.io.BufferedOutputStream.<init>()
方法的一些代码示例,展示了BufferedOutputStream.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedOutputStream.<init>()
方法的具体详情如下:
包路径:java.io.BufferedOutputStream
类名称:BufferedOutputStream
方法名:<init>
[英]Constructs a new BufferedOutputStream, providing out with a buffer of 8192 bytes.
[中]构造一个新的BufferedOutputStream,提供8192字节的缓冲区。
代码示例来源:origin: stanfordnlp/CoreNLP
public ByteStreamGobbler(String name, InputStream is, OutputStream out) {
super(name);
this.inStream = new BufferedInputStream(is);
this.outStream = new BufferedOutputStream(out);
}
代码示例来源:origin: libgdx/libgdx
private void writeFile (File outFile, byte[] bytes) {
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(outFile));
out.write(bytes);
} catch (IOException e) {
throw new RuntimeException("Couldn't write file '" + outFile.getAbsolutePath() + "'", e);
} finally {
if (out != null) try {
out.close();
} catch (IOException e) {
}
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
public static <T> void serializeCounter(Counter<T> c, String filename) throws IOException {
// serialize to file
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
out.writeObject(c);
out.close();
}
代码示例来源:origin: FudanNLP/fnlp
public void saveTo(String file) throws IOException {
File f = new File(file);
File path = f.getParentFile();
if(!path.exists()){
path.mkdirs();
}
ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(
new BufferedOutputStream(new FileOutputStream(file))));
out.writeObject(this);
out.close();
}
/**
代码示例来源:origin: apache/hive
public static void jarDir(File dir, String relativePath, ZipOutputStream zos) throws IOException {
Preconditions.checkNotNull(relativePath, "relativePath");
Preconditions.checkNotNull(zos, "zos");
// by JAR spec, if there is a manifest, it must be the first entry in
// the
// ZIP.
File manifestFile = new File(dir, JarFile.MANIFEST_NAME);
ZipEntry manifestEntry = new ZipEntry(JarFile.MANIFEST_NAME);
if (!manifestFile.exists()) {
zos.putNextEntry(manifestEntry);
new Manifest().write(new BufferedOutputStream(zos));
zos.closeEntry();
} else {
InputStream is = new FileInputStream(manifestFile);
copyToZipStream(is, manifestEntry, zos);
}
zos.closeEntry();
zipDir(dir, relativePath, zos, true);
zos.close();
}
代码示例来源:origin: alibaba/jstorm
public static void redirectOutput(String file) throws Exception {
System.out.println("Redirecting output to " + file);
FileOutputStream workerOut = new FileOutputStream(new File(file));
PrintStream ps = new PrintStream(new BufferedOutputStream(workerOut), true);
System.setOut(ps);
System.setErr(ps);
LOG.info("Successfully redirect System.out to " + file);
}
代码示例来源:origin: loklak/loklak_server
public static void gzip(File source, File dest, boolean deleteSource) throws IOException {
byte[] buffer = new byte[2^20];
GZIPOutputStream out = new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(dest), 65536)){{def.setLevel(Deflater.BEST_COMPRESSION);}};
FileInputStream in = new FileInputStream(source);
int l; while ((l = in.read(buffer)) > 0) out.write(buffer, 0, l);
in.close(); out.finish(); out.close();
if (deleteSource && dest.exists()) source.delete();
}
代码示例来源:origin: gocd/gocd
public boolean updateConsoleLog(File dest, InputStream in) {
File parentFile = dest.getParentFile();
parentFile.mkdirs();
LOGGER.trace("Updating console log [{}]", dest.getAbsolutePath());
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(dest, dest.exists()))) {
IOUtils.copy(in, out);
} catch (IOException e) {
LOGGER.error("Failed to update console log at : [{}]", dest.getAbsolutePath(), e);
return false;
}
LOGGER.trace("Console log [{}] saved.", dest.getAbsolutePath());
return true;
}
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* Gzip file.
*
* @param zipFileName
* @param mDestFile
* @throws Exception
*/
public static void gzips(String zipFileName, String mDestFile) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(zipFileName), "UTF-8"));
BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(mDestFile)));
int c;
while ((c = in.read()) != -1) {
out.write(String.valueOf((char) c).getBytes("UTF-8"));
}
in.close();
out.close();
}
代码示例来源:origin: redisson/redisson
protected DataOutputStream makeFileOutput(String directoryName) {
String classname = getName();
String filename = directoryName + File.separatorChar
+ classname.replace('.', File.separatorChar) + ".class";
int pos = filename.lastIndexOf(File.separatorChar);
if (pos > 0) {
String dir = filename.substring(0, pos);
if (!dir.equals("."))
new File(dir).mkdirs();
}
return new DataOutputStream(new BufferedOutputStream(
new DelayedFileOutputStream(filename)));
}
代码示例来源:origin: aporter/coursera-android
private void copyImageToMemory(File outFile) {
try {
BufferedOutputStream os = new BufferedOutputStream(
new FileOutputStream(outFile));
BufferedInputStream is = new BufferedInputStream(getResources()
.openRawResource(R.raw.painter));
copy(is, os);
} catch (FileNotFoundException e) {
Log.e(TAG, "FileNotFoundException");
}
}
代码示例来源:origin: plantuml/plantuml
static public void copyToStream(File src, OutputStream os) throws IOException {
final InputStream fis = new BufferedInputStream(new FileInputStream(src));
final OutputStream fos = new BufferedOutputStream(os);
copyInternal(fis, fos);
}
代码示例来源:origin: redisson/redisson
final void process(Socket clnt) throws IOException {
InputStream in = new BufferedInputStream(clnt.getInputStream());
String cmd = readLine(in);
logging(clnt.getInetAddress().getHostName(),
new Date().toString(), cmd);
while (skipLine(in) > 0){
}
OutputStream out = new BufferedOutputStream(clnt.getOutputStream());
try {
doReply(in, out, cmd);
}
catch (BadHttpRequest e) {
replyError(out, e);
}
out.flush();
in.close();
out.close();
clnt.close();
}
代码示例来源:origin: stackoverflow.com
InputStream reader = new BufferedInputStream(
object.getObjectContent());
File file = new File("localFilename");
OutputStream writer = new BufferedOutputStream(new FileOutputStream(file));
int read = -1;
while ( ( read = reader.read() ) != -1 ) {
writer.write(read);
}
writer.flush();
writer.close();
reader.close();
代码示例来源:origin: libgdx/libgdx
public void flush () {
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
properties.storeToXML(out, null);
} catch (Exception ex) {
throw new RuntimeException("Error writing preferences: " + file, ex);
} finally {
if (out != null)
try {
out.close();
} catch (IOException e) {
}
}
}
代码示例来源:origin: gocd/gocd
private void backupConfigRepository(File backupDir) throws IOException {
File configRepoDir = systemEnvironment.getConfigRepoDir();
try (ZipOutputStream configRepoZipStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(new File(backupDir, CONFIG_REPOSITORY_BACKUP_ZIP))))) {
new DirectoryStructureWalker(configRepoDir.getAbsolutePath(), configRepoZipStream).walk();
}
}
代码示例来源:origin: Tencent/tinker
/**
* zip list of file
*
* @param resFileList file(dir) list
* @param zipFile output zip file
* @throws IOException
*/
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment) throws IOException {
ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), TypedValue.BUFFER_SIZE));
for (File resFile : resFileList) {
if (resFile.exists()) {
zipFile(resFile, zipout, "");
}
}
if (comment != null) {
zipout.setComment(comment);
}
zipout.close();
}
代码示例来源:origin: stanfordnlp/CoreNLP
public static ObjectOutputStream writeStreamFromString(String serializePath)
throws IOException {
ObjectOutputStream oos;
if (serializePath.endsWith(".gz")) {
oos = new ObjectOutputStream(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(serializePath))));
} else {
oos = new ObjectOutputStream(new BufferedOutputStream(
new FileOutputStream(serializePath)));
}
return oos;
}
代码示例来源:origin: voldemort/voldemort
private void gzipFile(String srcPath, String destPath) throws Exception {
byte[] buffer = new byte[1024];
FileOutputStream fileOutputStream = new FileOutputStream(destPath);
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fileOutputStream)));
FileInputStream fileInput = new FileInputStream(srcPath);
int bytes_read;
while((bytes_read = fileInput.read(buffer)) > 0) {
out.write(buffer, 0, bytes_read);
}
fileInput.close();
out.close();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Creates a tar ball.
*/
public WorkspaceSnapshot snapshot(AbstractBuild<?, ?> build, FilePath ws, String glob, TaskListener listener) throws IOException, InterruptedException {
File wss = new File(build.getRootDir(),"workspace.tgz");
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(wss.toPath()))) {
ws.archive(ArchiverFactory.TARGZ, os, glob);
} catch (InvalidPathException e) {
throw new IOException(e);
}
return new WorkspaceSnapshotImpl();
}
内容来源于网络,如有侵权,请联系作者删除!