use of com.joliciel.talismane.utils.io.DirectoryWriter in project talismane by joliciel-informatique.
the class TalismaneMain method getWriter.
private static Writer getWriter(File outFile, File inFile, boolean keepDirectoryStructure, Reader reader, String sessionId) throws IOException {
if (outFile == null)
return new BufferedWriter(new OutputStreamWriter(System.out, TalismaneSession.get(sessionId).getOutputCharset()));
if (inFile.isDirectory() && keepDirectoryStructure) {
outFile.mkdirs();
DirectoryWriter directoryWriter = new DirectoryWriter(inFile, outFile, TalismaneSession.get(sessionId).getSuffix(), TalismaneSession.get(sessionId).getOutputCharset());
return directoryWriter;
} else {
File outDir = outFile.getParentFile();
if (outDir != null)
outDir.mkdirs();
outFile.delete();
outFile.createNewFile();
return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), TalismaneSession.get(sessionId).getOutputCharset()));
}
}
Aggregations