📄 ioutil.java
字号:
package org.jbpm.util.io;
import java.io.*;
public class IoUtil {
private static final int BUFFER_SIZE = 512;
public static int transfer(InputStream in, OutputStream out) throws IOException {
int total = 0;
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = in.read( buffer );
while ( bytesRead != -1 ) {
out.write( buffer, 0, bytesRead );
total += bytesRead;
bytesRead = in.read( buffer );
}
return total;
}
public static byte[] readStream(InputStream in) throws IOException {
byte[] fileContents = null;
int fileSize = 0;
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = in.read(buffer);
while (bytesRead != -1) {
byte[] newFileContents = new byte[fileSize + bytesRead];
if (fileSize > 0) {
System.arraycopy(fileContents, 0, newFileContents, 0, fileSize);
}
System.arraycopy(buffer, 0, newFileContents, fileSize, bytesRead);
fileContents = newFileContents;
fileSize += bytesRead;
bytesRead = in.read(buffer);
}
return fileContents;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -