-->
Skip to main content

Posts

Create and Read Excel File in java [2021]

Create and Read Excel File in java [2021] On a Regular Basis, Developers need to Create and Read excel file in java either they have pre-existing files from other communication channels to read or they need to create one from data fetched from the database. Today we will see  how to create excel file in Java  how to read excel file in Java using the Apache POI library.  As java doesn't have support for reading and creating excel files so we need to use a third-party library to generate one which is provided by Apache as Apache POI. Contents What is Apache POI? Adding Apache POI Dependency Creating a Student Pojo Creating the Excel File Generating the Excel File Reading Excel File in Java Complete Source Code of ExcelUtil Class Excel Write Output Excel Read Output how to read excel file in java using eclipse Conclusion What is Apache POI? Apache POI(Poor Obfuscation Implementation) is a third-party library used to read and write XLS, XLSX ...

Convert to String from Byte Array In Java [2021]

Convert to String from Byte Array In Java [2021] To convert to String from Byte Array we can use the String class Constructors or Base64 Class method introduced in Java8. In this tutorial, we will cover how to convert to String from Byte Array in Java using 4 ways. In an earlier post, we have covered how to  Convert String to Byte Array in Java . Contents Convert to String from Byte Array in Java 1. Using new String(byte[] bytes) 2. Using new String(byte[] bytes,String charsetName) 3. Using new String(byte[] bytes,Charset charset) 4. Using Base64.getEncoder().encodeToString(byte[] src) Complete Example Conclusion References Convert to String from Byte Array in Java To get String from Byte Array in Java we will use the String class overloaded constructors and the Base64 class method introduced in Java8. Using new String(byte[] bytes) Using new String(byte[] bytes, String charsetName) throws  UnsupportedEncodingException Using new String(byte[] by...

Convert String to Byte Array In Java [2021]

Convert String to Byte Array In Java [2021]  In this tutorial, we will cover how to convert String to Byte Array in Java using 4 ways. In the recent tutorial, we have covered how to Convert to String from Byte Array in Java Contents Convert String to Byte Array in Java 1. Using getBytes() 2. Using getBytes(String charsetName) 3. Using getBytes(Charset charset) 4. Using Base64.getDecoder().decode(String src) Complete Example Conclusion References Convert String to Byte Array in Java To convert String to Byte Array in Java we will use the getBytes() overloaded method in the String class and the Base64 class method introduced in Java8. Using getBytes() Using getBytes(String charsetName) throws  UnsupportedEncodingException Using getBytes(Charset charset) Using Base64.getDecoder().decode(String src) 1. Using getBytes() This method directly converts String to byte[] array. // sample string String string = "javacodegeek.com"; System.out.println(string...