public String readResultFile(final CandidateSession candidateSession) { final File resultFile = getResultFile(candidateSession); if (!resultFile.exists()) { return null; } try { /* NB: We're using the fact that we're writing out as UTF-8 when storing these files */ return FileUtils.readFileToString(getResultFile(candidateSession), "UTF-8"); } catch (final IOException e) { throw QtiWorksRuntimeException.unexpectedException(e); } }
private void storeResultFile(final CandidateSession candidateSession, final QtiNode resultNode) { final File resultFile = getResultFile(candidateSession); FileOutputStream resultStream = null; try { resultStream = new FileOutputStream(resultFile); qtiSerializer.serializeJqtiObject(resultNode, new FileOutputStream(resultFile)); } catch (final Exception e) { throw QtiWorksRuntimeException.unexpectedException(e); } finally { ServiceUtilities.ensureClose(resultStream); } }