use of java.io.BufferedInputStream in project love-android by hagish.
the class LoveZip method zipPeekHasFileName.
/// warning, might be slow, shouldn't be used for every file access
private static boolean zipPeekHasFileName(File f, String sSearchFileName) {
//~ LoveVM.LoveLog(TAG,"zipPeekHasFileName path='"+f.getPath()+"' search='"+sSearchFileName+"'");
try {
InputStream is = new FileInputStream(f);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is, 8 * 1024));
try {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
String filename = ze.getName();
//~ LoveVM.LoveLog(TAG,"zipPeekHasFileName filename='"+filename+"'");
if (filename.equals(sSearchFileName))
return true;
}
} finally {
zis.close();
}
} catch (IOException e) {
LoveVM.LoveLogE(TAG, "zipPeekHasFileName:failed to open file", e);
}
return false;
}
use of java.io.BufferedInputStream in project hazelcast by hazelcast.
the class PhoneHome method fetchWebService.
private void fetchWebService(String urlStr) {
InputStream in = null;
try {
URL url = new URL(urlStr);
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/5.0");
conn.setConnectTimeout(TIMEOUT * 2);
conn.setReadTimeout(TIMEOUT * 2);
in = new BufferedInputStream(conn.getInputStream());
} catch (IOException ignored) {
EmptyStatement.ignore(ignored);
} finally {
IOUtil.closeResource(in);
}
}
use of java.io.BufferedInputStream in project caffeine by ben-manes.
the class AbstractTraceReader method readFile.
/** Returns the input stream, decompressing if required. */
private InputStream readFile(String filePath) throws IOException {
BufferedInputStream input = new BufferedInputStream(openFile(filePath), BUFFER_SIZE);
input.mark(100);
try {
return new XZInputStream(input);
} catch (IOException e) {
input.reset();
}
try {
return new CompressorStreamFactory().createCompressorInputStream(input);
} catch (CompressorException e) {
input.reset();
}
try {
return new ArchiveStreamFactory().createArchiveInputStream(input);
} catch (ArchiveException e) {
input.reset();
}
return input;
}
use of java.io.BufferedInputStream in project coursera-android by aporter.
the class ExternalFileWriteReadActivity method copyImageToMemory.
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");
}
}
use of java.io.BufferedInputStream in project bazel by bazelbuild.
the class AndroidResourceValidatorAction method unpackZip.
private static void unpackZip(Path mergedResources, Path expandedOut) throws IOException {
byte[] buffer = new byte[4096];
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(Files.newInputStream(mergedResources)))) {
ZipEntry z = zis.getNextEntry();
while (z != null) {
String entryName = z.getName();
Path outputPath = expandedOut.resolve(entryName);
Files.createDirectories(outputPath.getParent());
try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(outputPath))) {
int count = zis.read(buffer);
while (count != -1) {
out.write(buffer, 0, count);
count = zis.read(buffer);
}
}
z = zis.getNextEntry();
}
}
}
Aggregations