mardi 8 décembre 2015

Convert java object in to pipe delimited string

Suppose there is class:

public class Employee 
{
   private String name;
   private String age;
   private String birthdate;
   private String location;
}

We have an object with values name = John, age = 25, birthdate = September 10, location = houston. Is there an easy way or an efficient way to convert that object into a pipe delimited string as shown below?

John|25|September 10|houston

I could think of only one solution - just appending the values of members of object into a string. I want to know if there is any better way to do this.

Aucun commentaire:

Enregistrer un commentaire