Now I have a task about Java IO , I need to read file line by line and save this data into database, But Now I got a problem.
\"desk\",\"12\",\"15\",\"(small
You could solve this by using Pattern
and Matcher
. Any solution using split would just seem like a nasty workaround. Here's an example:
public static void main(String[] args){
String s = "\"desk\",\"12\",\"15\",\"(small,median,large)\"";
Pattern p = Pattern.compile("\".+?\"");
Matcher m = p.matcher(s);
List matches = new ArrayList();
while (m.find()){
matches.add(m.group());
}
System.out.println(matches);
}