Witam, mam 2 problemy. Kod ponizej (pomijam wyjatki/bloki/itd)
HttpResponse response = null;
try {
response = client.execute(post);
} catch (costam) {;}
HttpEntity entity = response.getEntity();
String inputLine = "";
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(entity.getContent()));
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine); // **na wyjsciu widze, ze inputLine = "test"**
catch (itd) {;}
FileOutputStream fos = null;
try {
fos = new FileOutpuStream(mojPlik);
entity.writeTo(fos); // **tutaj komunikat: attempted read from closed stream exception**
catch (costam) {;}
finally {in.close(); fos.close();}
assertEquals("test", inputLine); // **tutaj komunikat: expected <test> but was: <null>**
Typy HttpEntity, HttpPost, itd - apache 4+. Jesli w petli while zmienna inputLine jest rowna "test", a poza petla nawet nie pustemu stringowi, tylko null, tzn, ze objekt na ktory wskazywala przestal istniec? Z kolei blad "attempted to read from closed stream" - nie wiem nawet czemu mogloby sie tak dziac... jedyna methoda wywolana na "entity" to getContent() - w dokumentacji napisali, ze "konsumuje" moj obiekt entity, ale nie chyba nie wywoluje close()?