MCPcopy Create free account
hub / github.com/PCGen/pcgen / output

Method output

code/src/java/pcgen/persistence/lst/CampaignOutput.java:53–86  ·  view source on GitHub ↗

@param campaign

(LoadContext context, Campaign campaign)

Source from the content-addressed store, hash-verified

51 * @param campaign
52 */
53 public static void output(LoadContext context, Campaign campaign)
54 {
55 final File outFile = new File(
56 ConfigurationSettings.getPccFilesDir() + File.separator + campaign.getSafe(StringKey.DESTINATION));
57
58 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")))
59 {
60
61 List<String> commentList = campaign.getListFor(ListKey.COMMENT);
62 if (commentList != null)
63 {
64 for (String s : commentList)
65 {
66 FileAccess.write(out, "#" + s);
67 FileAccess.newLine(out);
68 }
69 }
70
71 Collection<String> lines = context.unparse(campaign);
72 if (lines != null)
73 {
74 for (String line : lines)
75 {
76 FileAccess.write(out, line);
77 FileAccess.newLine(out);
78 }
79 }
80 } catch (IOException exc)
81 {
82 Logging.errorPrint("Error while writing to " + outFile.toString(), exc);
83
84 //TODO: Is this ok? Shouldn't something be done if writing a campaign fails?
85 }
86 }
87}

Callers 1

writeCustomSourcesMethod · 0.95

Calls 8

getPccFilesDirMethod · 0.95
writeMethod · 0.95
newLineMethod · 0.95
errorPrintMethod · 0.95
getSafeMethod · 0.80
getListForMethod · 0.65
unparseMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected