Problems reading text file data in Java

Posted by user1828401 on Stack Overflow See other posts from Stack Overflow or by user1828401
Published on 2012-11-18T16:23:40Z Indexed on 2012/11/18 17:01 UTC
Read the original article Hit count: 108

Filed under:

I have this code:

  BufferedReader br =new BufferedReader(new FileReader("userdetails.txt"));
     String str;
     ArrayList<String> stringList = new ArrayList<String>();
     while ((str=br.readLine())!=null){
        String datavalue [] = str.split(",");
        String category = datavalue[0];
        String value = datavalue[1];
        stringList.add(category);
        stringList.add(value);
     }
     br.close();

it works when the variables category and value do not have a comma(,),however the values in the variable value does contain commas.Is there a way that I can split the index of the without using comma?

© Stack Overflow or respective owner

Related posts about java