【发布时间】:2013-09-03 06:07:56
【问题描述】:
我是这样打的:
byte[] mockByteArray = PowerMock.createMockAndExpectNew(byte[].class, 10);
但是我遇到了运行时异常:找不到对象方法!如何解决?
[编辑]
我想模拟一个RandomAccessFile.read(byte[] buffer):
byte[] fileCutter(RandomAccessFile randomAccessFile, long position, int filePartSize) throws IOException{
byte[] buffer = new byte[filePartSize];
randomAccessFile.seek(position);
randomAccessFile.read(buffer);
return buffer;
}
【问题讨论】:
-
为什么要模拟一个字节数组?为什么不简单地创建一个普通的字节数组?
-
因为我想模拟一个 RandomAccessFile.read(byte[] buffer):
byte[] fileCutter(RandomAccessFile randomAccessFile, long position, int filePartSize) throws IOException{ byte[] buffer = new byte[filePartSize]; randomAccessFile.seek(position); randomAccessFile.read(buffer); return buffer; } -
我是新手,不知道如何正确编辑代码。原谅我,:(