Results 1 to 2 of 2
Thread: Delete Empty Spaces...
- 04-15-2009, 08:02 PM #1
Delete Empty Spaces...
I got a jtxtfieldPath declare at up there to receive folder path from the user.
Then at the event handling part,this is the code:
File f1=new File(jtxtfieldPath.getText());
If the user input something like this at the text field,it will crash:
C:\users\aaa aaa aaa
It is because of the space...
What do I need to modified at the jtxtfieldPath.getText() part in order to eliminate all the empty spaces?
- 04-15-2009, 09:59 PM #2
It is not the empty spaces that are giving you trouble... it is the backslashes... You need to escape them with another "\"... so it will be:
C:\\users\\aaa aaa aaa
String fileSep = System.getProperty( "file.separator" ); String theFilePath ="C:"+fileSep+"Documents and Settings"+fileSep+"Manager"+fileSep+"my file test.txt"; File file = new File(theFilePath);Who Cares... As Long As It Works...
- By JordashTalon in forum New To JavaReplies: 6Last Post: 02-26-2009, 01:26 AM
- By soc86 in forum New To JavaReplies: 3Last Post: 11-02-2008, 02:01 AM
- By Franneldort in forum New To JavaReplies: 13Last Post: 10-30-2008, 04:48 PM
- By barkster in forum Java AppletsReplies: 0Last Post: 01-30-2008, 09:40 PM
- By baltimore in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:31 AM