Append a record to the end of a text file: Difference between revisions
Append a record to the end of a text file (view source)
Revision as of 00:09, 11 May 2023
, 1 year ago→{{header|Java}}
Jazzedpineda (talk | contribs) (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;
|