📄 copyfile.java
字号:
package barprint.print;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* 实现文件拷贝,--字体安装功能
* @param from String
* @param to String
* @throws IOException
*/
public class CopyFile {
private String str_from;
private String str_to;
CopyFile(String from, String to){
str_from = from;
str_to = to;
try {
copy(str_from, str_to);
} catch (IOException ex) {
}
}
public void copy(String from, String to) throws IOException {
int BUFF_SIZE = 100000;
byte[] buffer = new byte[BUFF_SIZE];
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(from);
out = new FileOutputStream(to);
while (true) {
synchronized (buffer) {
int amountRead = in.read(buffer);
if (amountRead == -1) {
break;
}
out.write(buffer, 0, amountRead);
}
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -