Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Java in General
Using substring
Martin Bluck
Greenhorn
Posts: 25
I like...
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm trying to use the substring function to access a specific part of a
string
.
I can use it like this to access the temperature at the end.
String line = "#2014/01/01;45.6C;31.7"; String cutLine = line.substring(18); System.out.println(cutLine);
Which gives me
31.7
But I'd like to know if there's a way that I can access
45.6
only?
Salil Wadnerkar
Ranch Hand
Posts: 180
1
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You could have saved time by googling the substring API:
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
K. Tsang
Bartender
Posts: 3648
16
I like...
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Looking at the line data, there are 3 possible data values: "#2014/01/01", "45.6C" and "31.7". Do you see what separates them?
Are all 3 values relevant?
Substring isn't a good approach in such situation. Have a more closer look at the String API. Hint array return type.
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
OutputStreamWriter limitations.
using BufferedReader.readLine()
Screen Scrapping Problem!
passing value from jcombobox to other classes?
Java Object Oriented Temperature Conversion Program
More...