use of java.io.BufferedWriter in project screenbird by adamhub.
the class FileUtilTest method createFile.
public void createFile(String name) throws IOException {
properties = folder.newFile(name);
BufferedWriter out = new BufferedWriter(new FileWriter(properties));
out.write("this simulates a jpg file");
out.close();
}
use of java.io.BufferedWriter in project archaius by Netflix.
the class DynamicFileConfigurationTest method createConfigFile.
static File createConfigFile(String prefix) throws Exception {
configFile = File.createTempFile(prefix, ".properties");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), "UTF-8"));
writer.write("dprops1=123456789");
writer.newLine();
writer.write("dprops2=79.98");
writer.newLine();
// this property should fail validation but should not affect update of other properties
writer.write("abc=-2");
writer.newLine();
writer.close();
System.err.println(configFile.getPath() + " created");
return configFile;
}
use of java.io.BufferedWriter in project archaius by Netflix.
the class DynamicFileConfigurationTest method modifyConfigFile.
static void modifyConfigFile() {
new Thread() {
public void run() {
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), "UTF-8"));
// this property should fail validation but should not affect update of other properties
writer.write("abc=-8");
writer.newLine();
writer.write("dprops1=" + String.valueOf(Long.MIN_VALUE));
writer.newLine();
writer.write("dprops2=" + String.valueOf(Double.MAX_VALUE));
writer.newLine();
writer.close();
System.err.println(configFile.getPath() + " modified");
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
}
}.start();
}
use of java.io.BufferedWriter in project mounts2sd by SpazeDog.
the class FragmentTabLog method saveLogEntry.
public void saveLogEntry() {
File sdcardPath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getParent() + "/Mounts2SD");
File logFile = new File(sdcardPath, "log.txt");
sdcardPath.mkdirs();
try {
BufferedWriter output = new BufferedWriter(new FileWriter(logFile.getAbsolutePath(), false));
for (int i = 0; i < oLogEntry.length; i++) {
output.write(oLogEntry[i] + "\r\n");
}
output.close();
Toast.makeText(getActivity(), String.format(getResources().getString(R.string.toast_log_copied), logFile.getAbsolutePath()), Toast.LENGTH_LONG).show();
} catch (Throwable e) {
Toast.makeText(getActivity(), getResources().getString(R.string.toast_log_unsuccessful), Toast.LENGTH_LONG).show();
}
}
use of java.io.BufferedWriter in project android_frameworks_base by ParanoidAndroid.
the class WindowManagerService method viewServerListWindows.
/**
* Lists all availble windows in the system. The listing is written in the
* specified Socket's output stream with the following syntax:
* windowHashCodeInHexadecimal windowName
* Each line of the ouput represents a different window.
*
* @param client The remote client to send the listing to.
* @return False if an error occured, true otherwise.
*/
boolean viewServerListWindows(Socket client) {
if (isSystemSecure()) {
return false;
}
boolean result = true;
WindowList windows = new WindowList();
synchronized (mWindowMap) {
//noinspection unchecked
final int numDisplays = mDisplayContents.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
windows.addAll(displayContent.getWindowList());
}
}
BufferedWriter out = null;
// Any uncaught exception will crash the system process
try {
OutputStream clientStream = client.getOutputStream();
out = new BufferedWriter(new OutputStreamWriter(clientStream), 8 * 1024);
final int count = windows.size();
for (int i = 0; i < count; i++) {
final WindowState w = windows.get(i);
out.write(Integer.toHexString(System.identityHashCode(w)));
out.write(' ');
out.append(w.mAttrs.getTitle());
out.write('\n');
}
out.write("DONE.\n");
out.flush();
} catch (Exception e) {
result = false;
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
result = false;
}
}
}
return result;
}
Aggregations