@param campaign
(LoadContext context, Campaign campaign)
| 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 | } |
no test coverage detected