Alternative to java.nio.file.Files in Java 6

java

Solution

Alternative are classes from java.io or Apache Commons IO, also Guava IO can help.

Guava is most modern, so I think it is the best solution for you.

Read more: Guava's I/O package utilities, explained.

Problem

I have the following piece of code that uses the java 7 features like java.nio.file.Files and java.nio.file.Paths ``` import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.ObjectNode; public class JacksonObjectMapper { public static void main(String[] args) throws IOException { byte[] jsonData = Files.readAllBytes(Paths.get("employee.txt")); ObjectMapper objectMapper = new ObjectMapper(); Employee emp = objectMapper.readValue(jsonData, Employee.class); System.out.println("Employee Object\n"+emp); Employee emp1 = createEmployee(); objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); StringWriter stringEmp = new StringWriter(); objectMapper.writeValue(stringEmp, emp1); System.out.println("Employee JSON is\n"+stringEmp); } } ``` Now I have to run the the same code on Java 6 , what are the best possible alternatives other than using FileReader ?

Original source

Related problems