Java Utililty Methods PrintWriter Write

List of utility methods to do PrintWriter Write

Description

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

Method

voidsave(final Multimap map, final Writer target, final String sep)
save
assert map != null;
assert target != null;
if (map.isEmpty()) {
    return;
PrintWriter writer = new PrintWriter(new BufferedWriter(target));
for (String key : map.keySet()) {
    for (String value : map.get(key)) {
...
voidsave(Map map, String fileName)
save
try {
    save(map, new FileOutputStream(fileName));
} catch (IOException e) {
    throw new RuntimeException(e);
voidsave(String fileName, List list)
save
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
for (String title : list)
    pw.println(title);
pw.close();
voidsave(String s, File file)
save
try {
    PrintWriter out = new PrintWriter(file);
    out.println(s);
    out.flush();
    out.close();
} catch (Exception e) {
    e.printStackTrace();
voidsaveChiPhiTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
Save Chi and Phi coefficients as .csv file.
String line;
line = "Chi;";
for (String labelName : labelNames) {
    line += labelName + ";";
wr.write(line);
wr.write(System.getProperty("line.separator"));
for (int i = 0; i < labelNames.length; i++) {
...
voidsaveConvert(final String text, final int escapeMode, final PrintWriter writer)
Performs the necessary conversion of an java string into a property escaped string.
if (text == null) {
    return;
final char[] string = text.toCharArray();
final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
for (int x = 0; x < string.length; x++) {
    final char aChar = string[x];
    switch (aChar) {
...
voidsaveFile(File f, String text)
Given a file to write to, and data to write to it, it will write the data.
try (PrintWriter out = new PrintWriter(f)) {
    out.println(text);
} catch (IOException ioex) {
    System.out.println("Could not write to file " + f.toString());
voidsaveFile(String fileName, String data)
save File
PrintWriter writer = null;
try {
    writer = new PrintWriter(fileName, "UTF-8");
    writer.print(data);
} catch (FileNotFoundException | UnsupportedEncodingException e) {
    e.printStackTrace();
} finally {
    if (writer != null)
...
voidsaveFile(String path, String text)
save File
PrintWriter out;
try {
    out = new PrintWriter(path);
    out.print(text);
    out.close();
} catch (FileNotFoundException e) {
    throw e;
voidsaveHeatmapTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
Save heatmap table as .csv file
String line = new String();
line += " ;";
for (String labelName : labelNames) {
    line += labelName + ";";
wr.write(line);
wr.write(System.getProperty("line.separator"));
for (int i = 0; i < labelNames.length; i++) {
...