Store different lines of text separately, and store text in the same row

Source: Internet
Author: User

Store different lines of text separately, and store text in the same row

public class KL {    public Map<String, ArrayList<String>> CalcuP(String path) throws IOException      {                     Map<String, ArrayList<String>> map=new HashMap<String, ArrayList<String>>();                     BufferedReader reader = new BufferedReader(new FileReader(path));          String line = null;          ArrayList<String> list = new ArrayList<String>();          while ((line = reader.readLine()) != null) {           list.add(line);          }                              reader.close();                      String list0 = list.get(0);          String list1 = list.get(1);          String list2 = list.get(2);          String list3 = list.get(3);          ArrayList<String>    splist1=new ArrayList<String>(Arrays.asList(list0.split("\t")));          ArrayList<String>    splist2=new ArrayList<String>(Arrays.asList(list1.split("\t")));          ArrayList<String>    splist3=new ArrayList<String>(Arrays.asList(list2.split("\t")));          ArrayList<String> splist4=new ArrayList<String>(Arrays.asList(list3.split("\t")));          map.put("a",splist1);          map.put("b",splist2);          map.put("c",splist3);          map.put("d",splist4);          return map;    }                                       public static void main(String[] args) throws IOException {        KL t=new KL();        String path=("filename");        Map<String, ArrayList<String>> map=t.CalcuP(path);        ArrayList<String> a = map.get("a");        ArrayList<String> b = map.get("b");        ArrayList<String> c = map.get("c");        ArrayList<String> d = map.get("d");                    }}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.