This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

End of the string in java  RSS feed

 
vin Hari
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear experts,

please inform me how to check the end of the string in java,

as i have one string, which keeps on appending at runtime which mainly takes a file name,

so after it finishes in getting the whole string i can query otherwise it gives me wrong results

for example:


here i have to check : if i enter a file name test.abc



here on splitting the file on .(dot) i have to check if this not the extensio(abc) , if not error other wise no action

so in this case i get a extenstion not equal to abc ( ) as the string it reads in this format like,



so till last option first two times it goes for which is not the desired

please help me how to achieve this.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhm, I'm not sure if I really understood the problem but are you trying to check the extension of the filename ??

In that case, use lastIndexOf(".")
 
Vijitha Kumara
Bartender
Posts: 3992
27
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked what the "file1" contains at runtime?
 
Rob Spoor
Sheriff
Posts: 21047
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you ignore the case you can also simply use the endsWith method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!