I've used the split method and passed over the resulting array to get: {Greg, Roberts, Display(10).java}
How do I get rid of the (10) in the last string in the array? I've tried passing over it with loops using charAt but it seemingly won't get rid of the (10). I also need this to work with variations, like Display(950).java or DisplayFrame(555).java. [ November 17, 2005: Message edited by: Greg Roberts ]
Greg Roberts<br />CIS Student<br />University of West Florida
Michael Lloyd Lee
Greenhorn
Joined: Sep 07, 2005
Posts: 22
posted
0
I think the problem you are having is down to you trying to change the string, you can not. It is immutablem you have to create a new string, and assign it. i.e.
I'm not entirely sure how that (10) ended up there in the first place, as it is not in your original String:
"Greg Roberts - 99444005 - Display.java";
We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!
Greg Roberts
Ranch Hand
Joined: Feb 05, 2005
Posts: 72
posted
0
Yeah, that was my fault, I forgot to put the (10) in the example. Fixed it.
Greg Roberts
Ranch Hand
Joined: Feb 05, 2005
Posts: 72
posted
0
I'm trying to make use of the mkdir() and renameTo() methods of the File class, but the API is a little vague on their usage. Can anybody post some examples of the syntax, and what the output would produce?
I've got an ArrayList of files, and I need to create a directory based on the names of the files and drop the files in the directories that were made from their filenames.
The regular expression stuff is probably the quickest way to do it. But you kinda hafta learn how to do that sort of thing.
Without it .... hmmmm.... how about
String s = "Display(10).java"; // you'll get this string some other way String left = s.substring(0, s.indexOf('(')); // left is now "Display" String right = s.substring(s.indexOf(')') + 1, s.length()); // right is now ".java"
Here's how I ended up doing it. I wonder which way would be more efficient. This code is inside another for loop that is looping through an ArrayList of files.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.