stringtokenizer

Java StringTokenizer, empty null tokens

别等时光非礼了梦想. 提交于 2019-12-18 20:48:52
问题 I am trying to split a string into 29 tokens..... stringtokenizer won't return null tokens. I tried string.split, but I believe I am doing something wrong: String [] strings = line.split(",", 29); sample inputs: 10150,15:58,23:58,16:00,00:00,15:55,23:55,15:58,00:01,16:03,23:58,,,,,16:00,23:22,15:54,00:03,15:59,23:56,16:05,23:59,15:55,00:01,,,, 10155,,,,,,,,,,,07:30,13:27,07:25,13:45,,,,,,,,,,,07:13,14:37,08:01,15:23 10160,10:00,16:02,09:55,16:03,10:06,15:58,09:48,16:07,09:55,16:00,,,,,09:49

Read data from a text file and create an object

泪湿孤枕 提交于 2019-12-18 12:42:10
问题 I need some help: I'm making a Supermarket simulation on Java, but I've got one problem, I have a text file (Stock.txt) where I have all the supermarket stock on it for example: 0-Bakery-Chocolate Cake-$12.5-250 1-Meat-Premium Steak-$2.6-120 2-Seafood-Tuna - $1.2-14 ... Where the first number is the "id" for the product, next is the department the product belongs, third is the name of the product, the next thing is the price, and the last number is how much pieces of the product the stock has

Does PL/SQL have an equivalent StringTokenizer to Java's?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 06:48:31
问题 I use java.util.StringTokenizer for simple parsing of delimited strings in java. I have a need for the same type of mechanism in pl/sql. I could write it, but if it already exists, I would prefer to use that. Anyone know of a pl/sql implementation? Some useful alternative? 回答1: PL/SQL does include a basic one for comma separated lists ( DBMS_UTILITY.COMMA_TO_TABLE ). Example: DECLARE lv_tab_length BINARY_INTEGER; lt_array DBMS_UTILITY.lname_array; BEGIN DBMS_UTILITY.COMMA_TO_TABLE( list =>

Private Methods Over Public Methods

心不动则不痛 提交于 2019-12-17 23:44:32
问题 I was examining the StringTokenizer.java class and there were a few questions that came to mind. I noticed that the public methods which are to be used by other classes invoked some private method which did all of the work. Now, I know that one of the principles of OOD is to make as much as you can private and hide all of the implementation details. I'm not sure I completely understand the logic behind this though. I understand that it's important to make fields private to prevent invalid

Capitalize first word of a sentence in a string with multiple sentences

笑着哭i 提交于 2019-12-17 09:59:48
问题 eg: String s="this is a.line is .over " should come out as "This is a.Line is.Over" I thought of using string tokenizer twice -first split using"." -second split using " " to get the first word -then change charAt[0].toUpper now i'm not sure how to use the output of string tokenizer as input for another? also i can using the split method to generate array something i tried String a="this is.a good boy"; String [] dot=a.split("\\."); while(i<dot.length) { String [] sp=dot[i].split(" "); sp[0]

StringTokenizer countTokens() returns 1 with any string

流过昼夜 提交于 2019-12-13 07:59:07
问题 Here is my code: StringTokenizer line = new StringTokenizer("{([]{()})({})}"); System.out.println("Count: " + line.countTokens()); The output is always Count: 1 I know this shouldn't he happening with such a simple code. Could there be something wrong with the StringTokenizer library? Please help! 回答1: The default delimiter set of a StringTokenizer includes only whitespace characters, which aren't present in your string. http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html

String Tokenizer issue

半腔热情 提交于 2019-12-13 04:44:54
问题 AM using string tokenizer to delimit the string response by ^ 12/30/2011 12:00:00 AM^President^^^159^True^True^True^True^True^False^False^True^True^3/18/2011 12:00:00 AM^True^Jujama, Inc.^^^^True^True but the problem is when ^ delimiter consecutively its skipping that one and adding in to array. But i want to add space if two ^ delimiters comes. How to do that? My code is: StringTokenizer tokens = new StringTokenizer(partId, "^"); while(tokens.hasMoreTokens()){ String value=tokens.nextToken()

String manipulation for VML Path

痴心易碎 提交于 2019-12-13 03:55:17
问题 Hi I am trying to parse VML Path value using Java String manipulation. I want to retreive all the commands in the path like MoveTo , LineTo , CurveTo , RLineTo (other commands) and their corresponding x and y coordinates/parameters. Here are example data to parse, each command has their own x,y coordinates. 1. m1,1 l1,200,200,200,200,1 xe 2. m, l1,200,200,200,200,1 xe Can you suggest an algorithm or code on retreiving the commands and the parameters for each command? For example in number 1.

java StreamTokenizer

让人想犯罪 __ 提交于 2019-12-13 03:23:22
问题 I'm using the method quoteChar('"') to treat the strings. The usual escape sequences such as "\n" and "\t" are recognized and converted to single characters as the string is parsed. Is there any way to get the string just the way it is, meaning that if i have the string: Hello\tworld i want to get Hello\tworld and not: Hello world . Thanks 回答1: Looking at the StreamTokenizer source, it looks like the escape behavior for strings is hard-coded. I can only think of a few ways to get around it:

How to Tokenize String with Commas and Line Delimiter

荒凉一梦 提交于 2019-12-12 11:08:21
问题 I'm making a simple String Tokenizer in Swift like I would in Java...but it's really not working out for me. The end of each line in my data source delimited with "^" and the data is separated by comma's. For example: "string 1,string 2,string 3,^,string 1,string 2,string 3,^" This is what I would do in Java...(I only want the first two strings in each line of data) String delimeter = "^"; StringTokenizer tokenizedString = new StringTokenizer(responseString,delimeter); String [] stringArray =