use of java.io.FileOutputStream in project titan by thinkaurelius.
the class HBaseStatus method write.
public static HBaseStatus write(String path, String hbaseVersion) {
File f = new File(path);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(path);
fos.write(String.format("%s", hbaseVersion).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(fos);
}
return new HBaseStatus(f, hbaseVersion);
}
use of java.io.FileOutputStream in project Shuttle by timusus.
the class TaggerUtils method copyFile.
static void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.getParentFile().exists())
destFile.getParentFile().mkdirs();
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
destination.transferFrom(source, 0, source.size());
} finally {
if (source != null) {
source.close();
}
if (destination != null) {
destination.close();
}
}
}
use of java.io.FileOutputStream in project blueprints by tinkerpop.
the class GMLWriterTest method testEncoding.
// Note: this is only a very lightweight test of writer/reader encoding.
// It is known that there are characters which, when written by GMLWriter,
// cause parse errors for GraphMLReader.
// However, this happens uncommonly enough that is not yet known which characters those are.
public void testEncoding() throws Exception {
Graph g = new TinkerGraph();
Vertex v = g.addVertex(1);
v.setProperty("text", "é");
GMLWriter w = new GMLWriter(g);
File f = File.createTempFile("test", "txt");
f.deleteOnExit();
OutputStream out = new FileOutputStream(f);
w.outputGraph(out);
out.close();
Graph g2 = new TinkerGraph();
GMLReader r = new GMLReader(g2);
InputStream in = new FileInputStream(f);
r.inputGraph(in);
in.close();
Vertex v2 = g2.getVertex(1);
assertEquals("é", v2.getProperty("text"));
}
use of java.io.FileOutputStream in project robospice by stephanenicolas.
the class OkHttpBigBinaryRequest method processStream.
@Override
public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException {
OutputStream fileOutputStream = null;
try {
// touch
boolean isTouchedNow = cacheFile.setLastModified(System.currentTimeMillis());
if (!isTouchedNow) {
Ln.d("Modification time of file %s could not be changed normally ", cacheFile.getAbsolutePath());
}
fileOutputStream = new FileOutputStream(cacheFile);
readBytes(inputStream, new ProgressByteProcessor(this, fileOutputStream, contentLength));
return new FileInputStream(cacheFile);
} finally {
IOUtils.closeQuietly(fileOutputStream);
}
}
use of java.io.FileOutputStream in project robospice by stephanenicolas.
the class InFileInputStreamObjectPersisterTest method testLoadDataFromCache_expired.
public void testLoadDataFromCache_expired() throws Exception {
File cachedFile = inputStreamCacheManager.getCacheFile(TEST_CACHE_KEY);
FileOutputStream fileOutputStream = new FileOutputStream(cachedFile);
IOUtils.write("coucou", fileOutputStream);
IOUtils.closeQuietly(fileOutputStream);
cachedFile.setLastModified(System.currentTimeMillis() - FIVE_SECONDS);
InputStream inputStream = inputStreamCacheManager.loadDataFromCache(TEST_CACHE_KEY, DurationInMillis.ONE_SECOND);
assertNull(inputStream);
}
Aggregations