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

voidsaveLastExpInfo(String fileName, int[] info)
save Last Exp Info
if (info.length < 3)
    return;
File file = new File(fileName);
PrintWriter writer = new PrintWriter(file);
writer.println("NUM_USER " + info[0]);
writer.println("TYPE_SPD " + info[1]);
writer.println("EXP_ID " + info[2]);
writer.close();
...
voidsaveLine(File file, String line)
save Line
PrintWriter output = new PrintWriter(file);
output.print(line);
output.close();
voidsaveList(List list, OutputStream outs)
save List
PrintWriter out = new PrintWriter(outs);
for (int n = 0; n < list.size(); n++) {
    out.println(list.get(n));
out.flush();
out.close();
voidsaveMatrixAsADM(AtomicReferenceArray matrix, String path)
save Matrix As ADM
PrintWriter pw;
try {
    pw = new PrintWriter(path);
} catch (FileNotFoundException e) {
    e.printStackTrace();
    return;
for (int i = 0; i < matrix.length(); i++) {
...
booleansaveMineField(File fileName, String mineField)
save Mine Field
assert (fileName != null);
PrintWriter pos = null;
try {
    pos = new PrintWriter(new FileOutputStream(fileName, false), true);
} catch (Exception e) {
    e.printStackTrace(System.out);
try { 
...
voidsaveProbabilityData(String file, double[] probabilities, double start, double dt)
save Probability Data
try {
    File dataFile = new File(file + File.separator + "output.dat");
    PrintWriter writer = new PrintWriter(dataFile);
    for (int i = 0; i < probabilities.length; i++) {
        writer.println((start + (i * dt)) + "\t" + probabilities[i]);
    writer.close();
} catch (IOException e) {
...
voidsaveProcessedDataFile(double[][] data, String file)
Saves the given processed data to the specified file.
PrintWriter pw = new PrintWriter(file);
for (double[] point : data) {
    pw.printf("%f %f %f%n", point[0], point[1], point[2]);
pw.close();
voidsaveSet(Set set, File setFile, String encoding)
Save set as string to a file.
if (set != null) {
    PrintWriter printWriter = new PrintWriter(setFile, "utf-8");
    Iterator<?> iterator = set.iterator();
    while (iterator.hasNext()) {
        String value = iterator.next().toString();
        printWriter.println(value);
    printWriter.flush();
...
voidsaveSortedMap(Map map, File mapFile, String separator, String qualifier, String encoding)
Save map to a file in sorted key order.
if (map != null) {
    PrintWriter printWriter = new PrintWriter(mapFile, "utf-8");
    Set<Object> keySet = new TreeSet<Object>(map.keySet());
    Iterator<Object> iterator = keySet.iterator();
    while (iterator.hasNext()) {
        Object key = iterator.next();
        String value = map.get(key).toString();
        printWriter.println(qualifier + key + qualifier + separator + qualifier + value + qualifier);
...
voidsaveString(String theFilePath, String theString)
save String
createPath(theFilePath);
saveString(getOutputStream(theFilePath), theString);