double bytes = file.length();
double kilobytes = (bytes/1024);
double megaBytes = (kilobytes/1024);
if(megaBytes<10)
{
filesize = Double.toString(kilobytes);
System.out.println("kilobytes String : " + filesize);
try
{
arrByteFile = null;
int bytesRead;
int bufferSize = 1024;
FileInputStream is = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[bufferSize];
while ((bytesRead = is.read(b)) != -1)
{
bos.write(b, 0, bytesRead);
}
arrByteFile = bos.toByteArray();
is.close();
System.out.println("File byte array Size:-"+arrByteFile.length);
}
catch(Exception e)
{
e.printStackTrace();
}
try
{
ChunkOfByteArray chunkOfByteArray = new ChunkOfByteArray(arrByteFile);
arrayList = chunkOfByteArray.getChunksOfByteArray();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
如何處理內存不足錯誤?文件大於3Mb的內存不足錯誤雖然使用塊上載
有無論如何上傳Base64格式的大文件.. ??
我正在使用AQuery jar進行API調用並使用塊來上傳文件。但它僅在創建塊時發生錯誤。
感謝您的時間..
是的,先生..˚F或大型文件可能是我將不得不這樣做。感謝您的建議 – nadafafif 2014-10-10 10:10:35
@nadafafif這樣,無論文件大小如何,您都將使用1 KB(對於您的字節[])。 – 2014-10-10 10:15:05