Append a record to the end of a text file: Difference between revisions

(Omitted EasyLang)
Line 1,971:
 
=={{header|Java}}==
<syntaxhighlight lang="java">
 
import java.io.FileOutputStream;
import java.io.IOException;
</syntaxhighlight>
<syntaxhighlight lang="java">
void append(String path, byte[] data) throws IOException {
/* the second argument here is for appending bytes */
try (FileOutputStream output = new FileOutputStream(path, true)) {
output.write(data);
}
}
</syntaxhighlight>
<br />
An alternate implementation.
<syntaxhighlight lang="java">import static java.util.Objects.requireNonNull;
 
118

edits