I want to delimit ,\\s
but I also want to delimit \n
, what I thought of so far was ,\\s||\n
but this didn't work, anyone got an idea? It of course worked as a delimiter, but it gave back IPHONE , 7.0, 4, ., 7, A, false, 0
whilst I want back IPHONE 7, 4.7, A10, GSM, JET BLACK, 32GB, TRUE, 700
The file I'm scanning is this:
IPHONE 7, 4.7, A10, GSM, JET BLACK, 32GB, TRUE, 700
IPAD AIR 2, 9.7, A8, TRUE, SILVER, 64GB, 400
The code I'm using to scan it, is this:
public static iPhone read(Scanner sc) {
boolean touchtech = false;
//int price = 12;
sc.next();
sc.useDelimiter(",\\s||\n");
String model = sc.next();
double screensize = sc.nextDouble();
String processor = sc.next();
String modem = sc.next();
String color = sc.next();
String memory = sc.next();
String touchtechtest = sc.next();
if(touchtechtest.equals("TRUE")) {
touchtech = true;
}
int price = sc.nextInt();
sc.close();
iPhone res = new iPhone(model, screensize, processor, modem, color, memory, touchtech, price);
return res;
}