The post shows you how to create a temporary file and directory in java with an example. Main Code 1 package nio; 2 3 import java.io.IOException; 4 import java.nio.file.Files; 5 import java.nio.file.Path; 6 import java.nio.file.Paths; 7 8 public class Example1 { 9 public static void main(String[] args) throws IOException { 10 Path path = Files.createTempFile(“prefix”,…… Continue reading Creating a temporary file and directory
Tag: file
Deserialization of java objects present in JSON format from a file
This post will explain how to read the serialized (JSON) form of Java objects from a file. Person public class Person { private String fName; private String lName; private int age; public String getfName() { return fName; } public void setfName(String fName) { this.fName = fName; } public String getlName() { return lName; } public…… Continue reading Deserialization of java objects present in JSON format from a file
Serialization of java object in JSON format to a file
This post will explain how to save the serialized (JSON) form of Java objects to a file. Main Code import java.io.File; import java.io.FileWriter; import java.io.IOException; import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; public class JsonbDemo2 { public static void main(String[] args) throws IOException { Person person = new Person(); person.setfName(“fName”); person.setlName(“lName”); person.setAge(10); Jsonb jsonb = JsonbBuilder.create(); File file…… Continue reading Serialization of java object in JSON format to a file