-
Notifications
You must be signed in to change notification settings - Fork 320
Description
We are working on a research project for improving open-source projects by using the latest accepted answer from Stack Overflow that matches your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/questions/9293885.
The code to be improved is copy(File src, File dst) in https://github.com/SCADA-LTS/Scada-LTS/blob/develop/src/br/org/scadabr/db/configuration/ConfigurationDB.java Line#14-#25.
Type of Recommendation: Improve copy Method with Robust Resource Management and Performance Enhancement
Based on the comment by @Limraj :
It is better to use try-with-resources construct:
public static void copy(File src, File dst) throws IOException {
try(InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst)) {
byte[] buf = new byte[2048];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
}Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study https://drive.google.com/file/d/1ml5AqrtWQ9pnifTQyTFTcWQmwp6RuPA7/view?usp=sharing.