File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile time error with StringTokenizer" Watch "Compile time error with StringTokenizer" New topic

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\

I have to get only ""

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

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,"\\");
I agree. Here's the link:
subject: Compile time error with StringTokenizer