import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;import com.alibaba.fastjson.JSON;public class JsonMaker { public static void main(String[] args) { try { // read file content from file FileInputStream in = new FileInputStream("c://channels.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8")); String str = null; List list=new ArrayList(); while((str = br.readLine()) != null) { String[] s=str.split(","); channel c=new channel(s[0],s[1]); list.add(c); System.out.println(str); } @SuppressWarnings("unused") String res = JSON.toJSONString(list); br.close(); in.close(); } catch(FileNotFoundException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } } }