I want to copy the content of file \'A\' to file \'B\'.
after the copying is done I want to clear the content of file \'A\' and want to write on it from its beginning.
I can
With try-with-resources writer will be automatically closed:
import org.apache.commons.lang3.StringUtils;
final File file = new File("SomeFile");
try (PrintWriter writer = new PrintWriter(file)) {
writer.print(StringUtils.EMPTY);
}
// here we can be sure that writer will be closed automatically