Java Scanner - Delimit by spaces unless quotation marks are present?
问题 I'm trying to use the Scanner class in Java to get data from a configuration file. The file's elements are delimited by whitespace. However, if a phrase or element should be interpreted as a string literal (including whitespace), then double or single-quotes are places around the element. This gives files that look like this: > R 120 Something AWord > P 160 SomethingElse "A string literal" When using the Java Scanner class, it delimits by just whitespace by default. The Scanner class has the