feat: fix buffer
This commit is contained in:
@@ -58,6 +58,7 @@ public class Main {
|
||||
final byte[] encrypted = gcmCrypt(keyBytes, nonceBytes, true, resultBytes);
|
||||
writeFile(file, encrypted);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,11 +140,10 @@ public class Main {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final byte[] buffer = new byte[1024 * 8];
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
final int len = fis.read(buffer);
|
||||
if (len == -1) {
|
||||
return baos.toByteArray();
|
||||
int len;
|
||||
while ((len = fis.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
baos.write(buffer, 0, len);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Read file: " + file + " failed: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user