use of java.io.FileOutputStream in project VirtualApp by asLody.
the class VJobSchedulerService method saveJobs.
private void saveJobs() {
File jobFile = VEnvironment.getJobConfigFile();
Parcel p = Parcel.obtain();
try {
p.writeInt(JOB_FILE_VERSION);
p.writeInt(mJobStore.size());
for (Map.Entry<JobId, JobConfig> entry : mJobStore.entrySet()) {
entry.getKey().writeToParcel(p, 0);
entry.getValue().writeToParcel(p, 0);
}
FileOutputStream fos = new FileOutputStream(jobFile);
fos.write(p.marshall());
fos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
p.recycle();
}
}
use of java.io.FileOutputStream in project VirtualApp by asLody.
the class PersistenceLayer method save.
public void save() {
Parcel p = Parcel.obtain();
try {
writeMagic(p);
p.writeInt(getCurrentVersion());
writePersistenceData(p);
FileOutputStream fos = new FileOutputStream(mPersistenceFile);
fos.write(p.marshall());
fos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
p.recycle();
}
}
use of java.io.FileOutputStream in project VirtualApp by asLody.
the class FileUtils method copyFile.
public static void copyFile(File source, File target) throws IOException {
FileInputStream inputStream = null;
FileOutputStream outputStream = null;
try {
inputStream = new FileInputStream(source);
outputStream = new FileOutputStream(target);
FileChannel iChannel = inputStream.getChannel();
FileChannel oChannel = outputStream.getChannel();
ByteBuffer buffer = ByteBuffer.allocate(1024);
while (true) {
buffer.clear();
int r = iChannel.read(buffer);
if (r == -1)
break;
buffer.limit(buffer.position());
buffer.position(0);
oChannel.write(buffer);
}
} finally {
closeQuietly(inputStream);
closeQuietly(outputStream);
}
}
use of java.io.FileOutputStream in project VirtualApp by asLody.
the class FileUtils method writeToFile.
public static void writeToFile(InputStream dataIns, File target) throws IOException {
final int BUFFER = 1024;
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(target));
int count;
byte[] data = new byte[BUFFER];
while ((count = dataIns.read(data, 0, BUFFER)) != -1) {
bos.write(data, 0, count);
}
bos.close();
}
use of java.io.FileOutputStream in project baker-android by bakerframework.
the class Configuration method copyFile.
public static void copyFile(File source, File destination) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(source);
os = new FileOutputStream(destination);
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
} finally {
if (is != null)
is.close();
if (os != null)
os.close();
}
}
Aggregations