I’ve got around 10 lines of data in a text file below containing the following
X-Value = -0.525108, Y-Value = 7.746691, Z-Value = 5.863008, Timestamp(milliseconds) = 23001
X-Value = -0.755030, Y-Value = 7.861651, Z-Value = 6.016289, Timestamp(milliseconds) = 23208
The code I have right now uses a BufferedReader reading every line of the file but what I really want to do is extract the X-Value, Y-Value, Z-Value and Timestamp(milliseconds) values from each line. Could this be done with using simple String methods such as substring or would this suit the use of regular expressions?
You can first split the strings by
,s, then split each part by=, then trim leading/trailing spaces as necessary.You can use
String.split()orjava.util.StringTokenizerfor this.