Add method for converting gzip to string to Algorithms
This commit is contained in:
parent
9d4ebfadcf
commit
69f891c82f
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@ import net.osmand.PlatformUtil;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
|
@ -26,6 +27,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -452,6 +454,18 @@ public class Algorithms {
|
|||
return responseBody;
|
||||
}
|
||||
|
||||
public static String gzipToString(byte[] gzip) throws IOException {
|
||||
GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(gzipIs, "UTF-8"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
sb.append(s);
|
||||
}
|
||||
br.close();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean removeAllFiles(File f) {
|
||||
if (f == null) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue