auto commit

This commit is contained in:
CyC2018
2018-09-10 16:11:36 +08:00
2 changed files with 5 additions and 4 deletions

View File

@ -69,16 +69,17 @@ public static void listAllFiles(File dir) {
```java
public static void copyFile(String src, String dist) throws IOException {
FileInputStream in = new FileInputStream(src);
FileOutputStream out = new FileOutputStream(dist);
byte[] buffer = new byte[20 * 1024];
int cnt;
// read() 最多读取 buffer.length 个字节
// 返回的是实际读取的个数
// 返回 -1 的时候表示读到 eof即文件尾
while (in.read(buffer, 0, buffer.length) != -1) {
out.write(buffer);
while ((cnt = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, cnt);
}
in.close();