Java – Decompress a Gzip file
In previous article, we show how to compress a file in Gzip format. This article shows how to decompress a Gzip file. We copy the GZIPInputStream into a FileOutputStream to…
Favourite tutorials for developers
In previous article, we show how to compress a file in Gzip format. This article shows how to decompress a Gzip file. We copy the GZIPInputStream into a FileOutputStream to…
This article shows how to convert an object to byte or byte array and vice versa in Java. The example show how to use ByteArrayOutputStream and ObjectOutputStream to convert an…
This article shows a few ways to save a byte into a file. For JDK 1.7 and above, the NIO Files.write is the simplest solution to save byte to a…
In Java, we can use Files.readAllBytes(path) to convert a File object into a byte. Before Java 7, we can initiate a new byte with a predefined size (same with the…
In Java, we can use ByteArrayInputStream to convert a String to an InputStream. We will examine how to use ByteArrayInputStream to convert a String to an InputStream and saves it…
This article shows a few ways to convert an java.io.InputStream to a String. We will examine a few ways: using ByteArrayOutputStream, using InputStream#readAllBytes (Java 9), using InputStreamReader + StringBuilder, InputStreamReader…
In Java, we can use str.getBytes(StandardCharsets.UTF_8) to convert a String into a byte. And we can use new String(bytes, StandardCharsets.UTF_8) to convert byte to a String.
In Java, we can use new String(bytes, StandardCharsets.UTF_8) to convert a byte to a String. For text or character data, we use new String(bytes, StandardCharsets.UTF_8) to convert the byte to…
This article shows you a few ways to convert byte arrays or byte to a hexadecimal (base 16 or hex) string representative. String.format, Integer.toHexString, Apache Commons Codec – commons-codec, Spring…