Win a copy of Rust Web Development this week in the Other Languages forum!

Chris Cairns

Ranch Hand
+ Follow
since Jan 31, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Cairns

Hi all,
Any help would be appreciated.
My question concerns the split method in the String class.
Let's pretend I have a sequence of Strings in a text file that are tabbed delimited. And some of the Strings are simply empty but are still delimited by a tab. For example, Hello [tab] how [tab] [tab] you [tab] ? (Obviously this person is a foreigner with bad grammar and forgot "are".) After reading this line in and converting it to a String object, I use the split method. My question is this: how does the split method handle the blank/empty string? What character data does it return? Because when I try to print the bytes of this, no bytes are printed.
I have some follow up questions, but I'll wait for some answsers first.

Thanks!
18 years ago
Any help would be appreciated.
I have several rows of data I'm trying to parse and then insert into a database.

My approach to it has been this. I read the data, char by char, from the data file into a StringBuffer and convert that to a String. Now I have the all the text data as one huge String object. First, I split the String into an array of rows. (Each row is tabbed delimited.) Second, I split the rows into an array of fields. (All fields are tabbed delimited.) (The index number of the fields array corresponds exactly to its column position. So I simple just assign that position to a variable which I will later insert into the database.) Here's the thing. In the text data, not all field values exist. When I assign a field element to a variable if this is the case, nothing is assigned. I tried to print out the bytes to determine what character is there, but no bytes even print out. I even checked for null. I assume this has to do something with the split. I can't check use condition to determine whether or not the field has a value or not. I'm screwed because I won't be able to insert nulls. Any suggetions or do I need to clarify more?
18 years ago
Thanks! I'll try it out.
18 years ago
Problem: I need a more precise solution to parsing and insterting data into a database.
I'm parsing data in data file that has been exported from a database. Each field is tab delimited.


At first, I thought I could replace the tab character with a comma. Which would allow me to easily insert the record into the database. But what I found was that some of the field values actually contained a comma. This meant that in some cases, the the number of fields in a record would be larger than the number of columns. The long way around this problem I found was to replace the tabs with a colon. I won't get into the details of this. My co-worker tells me the shorter method is to replace the tabs with ',' so it'd be ready to be inserted immediately. However, parsing is done char by char and that sequence of characters is a string.

Any suggestions or are you totally lost by now?
18 years ago
Thanks for the reply. I'm currently trying the following code, but am getting a exception.

[ May 02, 2003: Message edited by: Chris Cairns ]
18 years ago
I want to convert the following date and time into milliseconds: 4/21/2003 21.50. I know how to convert milliseconds into a date, but not the other way around. Could someone, please, help?
18 years ago
I got the following error and am hoping that someone could explain why.
The error is: java.sql.SQLException: Closed Statement: next.
And it was produced because of the following order of statements:
I'm trying to create a utility method that will print out the records of any ResultSet. I'm trying to get the size of the ResultSet and to then print out the records in a for loop. I keep getting a SQL Exhaustion error in my current code, which I pasted below. Could someone please point me in the right direction.

[ April 25, 2003: Message edited by: Chris Cairns ]
How do you add a panel that's a separate class to a (background) panel that's a different class also?
18 years ago
I think what I can do is grab the character length of each row. If it's greater than 69, then I'll grab a substring from 0 to 69. If not, then don't grab a substring.
18 years ago
Here's the problem. I need to cutoff any text to the right of and including the following words: "1CFP", "CFP", "1TNK", "TNK", "1AL1", "Al1", "1ATC", "ATC", "1WBL", "WBL", "1SHP", "SHP". (See full text below.) The constraint is that I cannot use methods or packages from Java 1.4, just 1.3. This means no regex and no strObj.split(param). (I used the latter successfully to cutoff the text, but then found out that it had to be compatible with version 1.3). I've tried a few approaches with no success. I must admit, my problem is with the logic. So I'm hoping that someone could give me some pointers. I'd really appreciate it.

[ April 08, 2003: Message edited by: Chris Cairns ]
18 years ago
Hi Jason,
As part of my earlier solution, I used the method split() in the String class. Unfortunately, that's part of 1.4. Anyway I could do the same sort of thing you're talking about with regex?

Thanks!
18 years ago
Could someone explain to me what the conceptual difference is between the constructors of StringTokenizer? In particular, passing boolean false or true. Thanks!
18 years ago
I can't use anything from JDK 1.4. It has to be compatible with 1.3. Could I use StringTokenizer to solve my problem of cutting off the text?
18 years ago
Anyone know some good references on Exception Chaining?