Java Utililty Methods OutputStreamWriter Write

List of utility methods to do OutputStreamWriter Write

Description

The list of methods to do OutputStreamWriter Write are organized into topic(s).

Method

voidsaveListText(String filename, List array)
save List Text
Writer writer = null;
try {
    writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8"));
    for (double val : array) {
        writer.write(val + " ");
    writer.write("\n");
} catch (IOException ex) {
...
voidsaveLongTxtList(long[] ids, String[] texts, String listFile)
save Long Txt List
BufferedWriter bw = new BufferedWriter(
        new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(listFile))));
for (int i = 0; i < texts.length; i++) {
    bw.append(ids[i] + SEP + texts[i]);
    bw.newLine();
bw.flush();
bw.close();
...
voidsaveString(File f, String enc, String text)
save String
OutputStreamWriter osw = null;
try {
    osw = new OutputStreamWriter(new FileOutputStream(f), enc);
    osw.write(text);
    osw.flush();
} finally {
    if (osw != null) {
        osw.close();
...
voidsaveString(String string, File file, String charsetName)
save String
OutputStream out = new FileOutputStream(file);
try {
    saveString(string, out, charsetName);
} finally {
    out.close();
booleansaveString2File(String s, String filename)
save String File
return saveString2File(s, new File(filename));
booleansaveStringToFile(String filename, String string)
save String To File
boolean saved = false;
BufferedWriter bw = null;
if (string == null || filename == null) {
    throw new NullPointerException("Null String");
try {
    bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF-8"));
    try {
...
voidsaveStringToFile(String toSave, String fn)
Save the specifed string to the given file name
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fn)));
java.util.StringTokenizer st = new java.util.StringTokenizer(toSave, "\n", true);
String s;
while (st.hasMoreTokens()) {
    s = st.nextToken();
    if (s.equals("\n"))
        writer.newLine();
    else
...
voidsaveStringToPath(String stringToSave, String pathToSaveTo)
save String To Path
try {
    OutputStreamWriter oos = new OutputStreamWriter(new FileOutputStream(pathToSaveTo));
    oos.write(stringToSave);
    oos.close();
} catch (IOException e) {
    e.printStackTrace();
voidsaveText(BufferedWriter writer, String string)
Saves the given text to the specified BufferedWriter instance, then closes the writer afterwards.
writer.write(string);
writer.flush();
writer.close();
voidsaveTextInFile(File file, String content, String encoding)
Saves given text content to given file.
BufferedWriter bw = null;
try {
    bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));
    bw.write(content);
} catch (IOException ex) {
    throw new RuntimeException(ex.getMessage(), ex);
} finally {
    if (bw != null) {
...