• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java String Operations

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a jsp form the user enter the report file URL i.e., https://s3.amazonaws.com/cdn.gs.com/live/reports/MVR_Q3_2009.pdf or cdn.gs.com/live/reports/MVR_Q3_2009.pdf

But when the form is submitted, a java class(struts2 action) has to checks whether its a valid url by taking the cdn.gs.com as bucket name and /reports/MVR_Q3_2009.pdf as file path and then searches in the AWS s3 bucket.

For now we are getting the file_path from the url, but the cdn.gs.com is entered as a static variable before checking into S3.

Can we get the cdn.gs.com as bucket_name(string variable) from the URL https://s3.amazonaws.com/cdn.gs.com/live/reports/MVR_Q3_2009.pdf or cdn.gs.com/live/reports/MVR_Q3_2009.pdf
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sangram nani wrote:Can we get the cdn.gs.com as bucket_name(string variable) from the URL https://s3.amazonaws.com/cdn.gs.com/live/reports/MVR_Q3_2009.pdf or cdn.gs.com/live/reports/MVR_Q3_2009.pdf


Ofcourse you can do that. But to know how, you need to get clear for yourself what rules exactly you want to apply to find that part of the string. For example you could split the string by the '/' character and find the right element in the resulting array of strings. Once you have clear for yourself what rules you'd need to apply it's easy to do it with methods from class String.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic