File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile time error with StringTokenizer

 
shreehari Gopalakrishnan
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the code before StringTokenizer may be u have not closed the statements in previous lines.
 
Greg T Robertson
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic