| |||||||
Das Thema "Lesen eines GZipInputStreams" befindet sich unter Android App Entwicklung auf Android-Hilfe.de.
|
| | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Android-Hilfe.de Mitglied Modell: Samsung Galaxy S2 (I9100) Registriert seit: 24.10.2011
Beiträge: 77
Abgegebene Danke: 13
Erhielt 2 Danke für 2 Beiträge
| ich hab folgendes Problem und zwar versuche ich von einer URL eine GZip Datei als InputStream zu laden. Die GZip Datei wurde mit php erstellt, sollte also ein Standardformat sein, bin mir aber nicht 100% sicher dass das ein brauchbares Format. Hier mal die Methode Code:
public static InputStream getJsonStream(String url, boolean gzip)
{
try
{
HttpGet httpGet = new HttpGet(url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpGet);
if (gzip)
{
response.addHeader("Accept-Encoding", "gzip");
content = new GZIPInputStream(response.getEntity().getContent());
Log.v("### GZIP-Stream ###", url);
}
else
{
content = response.getEntity().getContent();
}
}
catch (Exception exc)
{
Log.v("### Exception ###", "Fehler beim Lesen der List JSON", exc);
}
return content;
} Code: ### Exception ###(13186): Fehler beim Lesen der List JSON ### Exception ###(13186): java.io.IOException: unknown format (magic number a5b) ### Exception ###(13186): at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:84) ### Exception ###(13186): at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:64) ### Exception ###(13186): at kommunikation.Server.getJsonStream(Server.java:66) ### Exception ###(13186): at kommunikation.Json.jsonLaden(Json.java:289) ### Exception ###(13186): at kommunikation.Json.access$1(Json.java:265) ### Exception ###(13186): at kommunikation.Json$AvailabilityTask.doInBackground(Json.java:208) ### Exception ###(13186): at kommunikation.Json$AvailabilityTask.doInBackground(Json.java:1) ### Exception ###(13186): at android.os.AsyncTask$2.call(AsyncTask.java:185) ### Exception ###(13186): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) ### Exception ###(13186): at java.util.concurrent.FutureTask.run(FutureTask.java:138) ### Exception ###(13186): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) ### Exception ###(13186): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) ### Exception ###(13186): at java.lang.Thread.run(Thread.java:1019) |
| | |
| | #2 (permalink) |
| Android Experte Registriert seit: 05.02.2010
Beiträge: 609
Abgegebene Danke: 75
Erhielt 136 Danke für 119 Beiträge
|
Vielleicht hab ich ja keine Ahnung, aber du fügst der Antwort hinzu, dass du gzip haben willst. Das sieht komisch aus. Solltest du das nicht in dem Request sagen? Achja, evtl hilft es weiter, wenn du dir einen Hexdump von deinem Content baust (die ersten 128byte oder so sollten ja reichen).
__________________ Kein Support via PN/eMail. Bitte das Forum benutzen - dort haben alle etwas davon. Bei Entwicklerfragen zu abstürzenden Apps bitte immer die Ausgabe von LogCat posten. Tipp: Zum "Danke" sagen gibt es einen Button. ![]() |
| | |
| Folgender Benutzer bedankt sich bei DieGoldeneMitte für diesen Beitrag: | samarek (23.11.2011) |
![]() |
|
| Themen-Optionen | |
| Ansicht | |
| |
| ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Emails lesen | yusuf68 | Sonstige Apps & Widgets | 0 | 09.07.2011 23:30 |
| [ ROM THREAD WICHTIG ] Vor der Neuverkündung eines ROM Lesen | Kjetal | Custom-Roms für Samsung Galaxy S2 | 3 | 07.07.2011 19:43 |
| QR Codes lesen? | Ehli | Motorola Flipout Forum | 6 | 23.08.2010 11:10 |
| EBooks lesen | xzeebee | Sonstige Apps & Widgets | 4 | 03.08.2010 07:38 |
| SMS lesen | cha-cha | Motorola Milestone Forum | 3 | 28.05.2010 09:35 |