Here you can find the source of splitNextWord(String line)
public static List<String> splitNextWord(String line)
//package com.java2s; /*/*from w w w.j av a2 s . c o m*/ * This software copyright by various authors including the RPTools.net * development team, and licensed under the LGPL Version 3 or, at your option, * any later version. * * Portions of this software were originally covered under the Apache Software * License, Version 1.1 or Version 2.0. * * See the file LICENSE elsewhere in this distribution for license details. */ import java.util.Arrays; import java.util.List; public class Main { public static List<String> splitNextWord(String line) { line = line.trim(); if (line.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); boolean quoted = line.charAt(0) == '"'; int start = quoted ? 1 : 0; int end = start; for (; end < line.length(); end++) { char c = line.charAt(end); if (quoted) { if (c == '"') { break; } } else { if (Character.isWhitespace(c)) { break; } } builder.append(c); } return Arrays.asList( new String[] { line.substring(start, end), line.substring(Math.min(end + 1, line.length())) }); } }