我在下面的代码中显示的行中得到了 ArrayIndexOutOfBoundsException:
String boundaryMessage = getBoundaryMessage(boundary, fileField, fileName, fileType);
String endBoundary = "\r\n--" + boundary + "--\r\n";
byte[] temp = new byte[boundaryMessage.getBytes().length+fileBytes.length+endBoundary.getBytes().length];
temp = boundaryMessage.getBytes();
try {
System.arraycopy(fileBytes, 0, temp, temp.length, fileBytes.length); //exception thrown here
System.arraycopy(endBoundary.getBytes(), 0, temp, temp.length, endBoundary.getBytes().length);
}
catch(Exception e){
System.out.println("====Exception: "+e.getMessage()+" Class: "+e.getClass());
}
有人可以指出我错在哪里。谢谢。