aspose file tools*
The moose likes Beginning Java and the fly likes Compile time error with StringTokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile time error with StringTokenizer" Watch "Compile time error with StringTokenizer" New topic
Author

Compile time error with StringTokenizer

shreehari Gopalakrishnan
Ranch Hand

Joined: Jun 01, 2004
Posts: 30
Hi Masters
I am gettiing a problem while initializing StringTokenizer

For an application i have to filter filename from its path

ie for ex:
from the string C:\java\begin\utilities\FileFinder.java

I have to get only "FileFinder.java"

for that i am using a StringTokenizer to separate the strings

I have written


StringTokenizer strTok = new StringTokenizer(str,"\");

In this statmt i am getting a compile time error

"String is not closed" or something like that

what should i do

is there any other good logic for this problem

masters to answer !
Rinky Deshmukh
Greenhorn

Joined: Jun 09, 2004
Posts: 16
check the code before StringTokenizer may be u have not closed the statements in previous lines.
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
Your problem is the StringTokenizer strTok = new StringTokenizer(str,"\"); the \ is the escape character for Strings. It should be StringTokenizer strTok = new StringTokenizer(str,"\\");
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compile time error with StringTokenizer