Results 1 to 3 of 3
Thread: Problem splitting a string
- 03-13-2011, 08:43 PM #1
Problem splitting a string
I am trying to split up a filename into parts:
My output is:Java Code:String filename = file.getName(); System.out.println("File: "+filename); String[] parts = filename.split("."); System.out.println(parts[0]);
File: hello.txt
Then I get an indexoutOfBounds exception when trying to print out parts[0].
I even went so far as to iterate over each character in the filename string and keep a count of the "." instances, and it gives me back a 1 so I know it recognizes the period...not sure whats going on.Last edited by sehudson; 03-13-2011 at 08:47 PM.
-
- 03-13-2011, 08:56 PM #3
Similar Threads
-
Intaking String and splitting into chars, returning individual chars as string array
By Gokul138 in forum New To JavaReplies: 1Last Post: 02-07-2011, 08:22 PM -
problem with "|" character while splitting text or string.
By fmuddy in forum Advanced JavaReplies: 3Last Post: 03-03-2010, 12:23 AM -
String Splitting
By A.M.S in forum New To JavaReplies: 1Last Post: 12-04-2009, 07:17 AM -
Splitting single string into array elements
By phil128 in forum New To JavaReplies: 11Last Post: 01-12-2009, 11:51 AM -
splitting string and replacing
By itsme in forum New To JavaReplies: 1Last Post: 12-11-2007, 03:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks