client.getOutputStream().write("\n".getBytes());

remoetInputStream = connection.getInputStream();
cacheOutputStream = new BufferedOutputStream(new FileOutputStream(
mCacheFile));

byte[] buf = new byte[BUF_SIZE];
int readSize;
while ((readSize = remoetInputStream.read(buf)) != -1 && !bStop) {
if (cacheOutputStream != null) {
try {
cacheOutputStream.write(buf, 0, readSize);
} catch (IOException e) {
Log.e("write cachefile", e);
try {
cacheOutputStream.close();
} catch (IOException ex) {
}
cacheOutputStream = null;
}
}
client.getOutputStream().write(buf, 0, readSize);
}
☆の位置でNullPointerExceptionが発生します
似たようなソースも見てみましたがNullPointerExceptionの対策がされてないようでした
本来はNullPointerExceptionが発生しない箇所なのでしょうか?
もしそうなら原因は何でしょうか?
URLはちゃんと接続できます