Top Description Fields Constructors Methods
org.jabref.logic.exporter

public Class AtomicFileWriter

extends OutputStreamWriter
Class Inheritance
Imports
java.io.IOException, .OutputStreamWriter, java.nio.charset.Charset, .CharsetEncoder, java.nio.file.Path, java.util.Collections, .Set, .TreeSet

Writer that similar to the built-in java.io.FileWriter but uses the AtomicFileOutputStream as the underlying output stream. In this way, we make sure that the errors during the write process do not destroy the contents of the target file. Moreover, this writer checks if the chosen encoding supports all text that is written. Characters whose encoding was problematic can be retrieved by getEncodingProblems().

Field Summary

Modifier and TypeField and Description
private final CharsetEncoder
private final Set<Character>

Constructor Summary

AccessConstructor and Description
public
AtomicFileWriter(Path file, Charset encoding)

public
AtomicFileWriter(Path file, Charset encoding, boolean keepBackup)

Method Summary

Modifier and TypeMethod and Description
public Set<Character>
public boolean
public void
write(String
String to be written
str
)

Overrides java.io.Writer.write.

Writes a string.

Inherited from java.io.OutputStreamWriter:
appendappendcloseflushgetEncodingwritewritewrite

Field Detail

encoderback to summary
private final CharsetEncoder encoder
problemCharactersback to summary
private final Set<Character> problemCharacters

Constructor Detail

AtomicFileWriterback to summary
public AtomicFileWriter(Path file, Charset encoding) throws IOException
AtomicFileWriterback to summary
public AtomicFileWriter(Path file, Charset encoding, boolean keepBackup) throws IOException

Method Detail

getEncodingProblemsback to summary
public Set<Character> getEncodingProblems()
hasEncodingProblemsback to summary
public boolean hasEncodingProblems()
writeback to summary
public void write(String str) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a string.

Parameters
str:String

String to be written

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs