• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

String Function

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a requirement like this

String filepath = "P:\\Folder1\\Folder2\\Folder3\\Folder4\\Folder5\\Folder6\\File.txt"

String filebase = "P:/Folder1/Folder2/Folder3/";

I want the result string should be filebase = "P:/Folder1/Folder2/Folder3/Folder4/Folder5/Folder6"

 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, and your question is?

BTW: there is this part of the API that deals with String... take a look, it may have your answers there... google "Java String API"

hariharan jayaprakash wrote:
I have a requirement like this

String filepath = "P:\\Folder1\\Folder2\\Folder3\\Folder4\\Folder5\\Folder6\\File.txt"

String filebase = "P:/Folder1/Folder2/Folder3/";

I want the result string should be filebase = "P:/Folder1/Folder2/Folder3/Folder4/Folder5/Folder6"

 
Bartender
Posts: 15743
368
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use String manipulations for this. There's a much safer API: java.nio.file.Path.
reply
    Bookmark Topic Watch Topic
  • New Topic