use of java.io.FileWriter in project platform_frameworks_base by android.
the class VideoDumpView method onResume.
@Override
public void onResume() {
Log.d(TAG, "onResume");
mMediaPlayer = new MediaPlayer();
try {
mMediaPlayer.setDataSource(VideoDumpConfig.VIDEO_URI);
class RGBFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(VideoDumpConfig.IMAGE_SUFFIX));
}
}
File dump_dir = new File(VideoDumpConfig.ROOT_DIR);
File[] dump_files = dump_dir.listFiles(new RGBFilter());
for (File dump_file : dump_files) {
dump_file.delete();
}
File image_list = new File(VideoDumpConfig.ROOT_DIR + VideoDumpConfig.IMAGES_LIST);
image_list.delete();
mImageListWriter = new BufferedWriter(new FileWriter(image_list));
} catch (java.io.IOException e) {
Log.e(TAG, e.getMessage(), e);
}
queueEvent(new Runnable() {
public void run() {
mRenderer.setMediaPlayer(mMediaPlayer);
mRenderer.setImageListWriter(mImageListWriter);
}
});
super.onResume();
}
use of java.io.FileWriter in project platform_frameworks_base by android.
the class DpmTestUtils method writeToFile.
public static void writeToFile(File path, String content) throws IOException {
path.getParentFile().mkdirs();
try (FileWriter writer = new FileWriter(path)) {
Log.i(DpmTestBase.TAG, "Writing to " + path);
Log.i(DpmTestBase.TAG, content);
writer.write(content);
}
}
use of java.io.FileWriter in project platform_frameworks_base by android.
the class CSVWriterFilter method onProcess.
@Override
protected void onProcess() {
Log.v(TAG, "in csv writer on process");
FrameValue sharpnessValue = getConnectedInputPort("sharpness").pullFrame().asFrameValue();
float sharpness = ((Float) sharpnessValue.getValue()).floatValue();
FrameValue overExposureValue = getConnectedInputPort("overExposure").pullFrame().asFrameValue();
float overExposure = ((Float) overExposureValue.getValue()).floatValue();
FrameValue underExposureValue = getConnectedInputPort("underExposure").pullFrame().asFrameValue();
float underExposure = ((Float) underExposureValue.getValue()).floatValue();
FrameValue colorfulnessValue = getConnectedInputPort("colorfulness").pullFrame().asFrameValue();
float colorfulness = ((Float) colorfulnessValue.getValue()).floatValue();
FrameValue contrastValue = getConnectedInputPort("contrastRating").pullFrame().asFrameValue();
float contrast = ((Float) contrastValue.getValue()).floatValue();
FrameValue brightnessValue = getConnectedInputPort("brightness").pullFrame().asFrameValue();
float brightness = ((Float) brightnessValue.getValue()).floatValue();
FrameValue motionValuesFrameValue = getConnectedInputPort("motionValues").pullFrame().asFrameValue();
float[] motionValues = (float[]) motionValuesFrameValue.getValue();
float vectorAccel = (float) Math.sqrt(Math.pow(motionValues[0], 2) + Math.pow(motionValues[1], 2) + Math.pow(motionValues[2], 2));
FrameValue imageFileNameFrameValue = getConnectedInputPort("imageFileName").pullFrame().asFrameValue();
String imageFileName = ((String) imageFileNameFrameValue.getValue());
FrameValue csvFilePathFrameValue = getConnectedInputPort("csvFilePath").pullFrame().asFrameValue();
String csvFilePath = ((String) csvFilePathFrameValue.getValue());
if (mFirstTime) {
try {
FileWriter fileWriter = new FileWriter(csvFilePath + "/CSVFile.csv");
BufferedWriter csvWriter = new BufferedWriter(fileWriter);
csvWriter.write("FileName,Sharpness,OverExposure,UnderExposure,Colorfulness," + "ContrastRating,Brightness,Motion");
csvWriter.newLine();
csvWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mFirstTime = false;
}
try {
Log.v(TAG, "about to write to file");
FileWriter fileWriter = new FileWriter(csvFilePath + mFileName, true);
BufferedWriter csvWriter = new BufferedWriter(fileWriter);
csvWriter.write(imageFileName + "," + sharpness + "," + overExposure + "," + underExposure + "," + colorfulness + "," + contrast + "," + brightness + "," + vectorAccel);
Log.v(TAG, "" + imageFileName + "," + sharpness + "," + overExposure + "," + underExposure + "," + colorfulness + "," + contrast + "," + brightness + "," + vectorAccel);
csvWriter.newLine();
csvWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of java.io.FileWriter in project antlr4 by antlr.
the class LogManager method save.
public void save(String filename) throws IOException {
FileWriter fw = new FileWriter(filename);
BufferedWriter bw = new BufferedWriter(fw);
try {
bw.write(toString());
} finally {
bw.close();
}
}
use of java.io.FileWriter in project platform_frameworks_base by android.
the class TaskPersister method writePersistedTaskIdsForUser.
@VisibleForTesting
void writePersistedTaskIdsForUser(@NonNull SparseBooleanArray taskIds, int userId) {
if (userId < 0) {
return;
}
final File persistedTaskIdsFile = getUserPersistedTaskIdsFile(userId);
synchronized (mIoLock) {
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(persistedTaskIdsFile));
for (int i = 0; i < taskIds.size(); i++) {
if (taskIds.valueAt(i)) {
writer.write(String.valueOf(taskIds.keyAt(i)));
writer.newLine();
}
}
} catch (Exception e) {
Slog.e(TAG, "Error while writing taskIds file for user " + userId, e);
} finally {
IoUtils.closeQuietly(writer);
}
}
}
Aggregations