我有个问题.我不知道byte['?']意味着什么; 它适用于所有类型的数组,但我很好奇它实际上做了什么.
private void copy(InputStream in, File file) {
try {
OutputStream out = new FileOutputStream(file);
byte[] buf = new byte['?'];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} catch (Exception localException) {
}
Run Code Online (Sandbox Code Playgroud)
表达'?'是一个char.它可以int隐式转换为整数.
该new byte[arraySize]预计arraySize为类型int.因此,'?'转换为整数,语句变为:
byte[] buf = new byte[63];
Run Code Online (Sandbox Code Playgroud)
因为63 == (int)'?'.