我正在编写一个涉及文件上传的 android 应用程序。有什么方法可以在不实际编写服务器端代码的情况下检查代码是否存在潜在的内存不足错误?如果是,请解释。代码如下: -
private void sendToRemoteServer(){
Socket client;
FileInputStream fileInputStream;
BufferedInputStream bufferedInputStream;
OutputStream outputStream;
try{
client = new Socket("10.0.2.2",444);
byte[] myByteArray = new byte[(int)mFile.length()];
fileInputStream = new FileInputStream(mFile);
bufferedInputStream = new BufferedInputStream(fileInputStream);
bufferedInputStream.read(myByteArray, 0, myByteArray.length); //read the file
outputStream = client.getOutputStream();
outputStream.write(myByteArray, 0, myByteArray.length); //write file to the output stream byte by byte
outputStream.flush();
bufferedInputStream.close();
outputStream.close();
client.close();
}catch(UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}