I have a text file with the name of "w1_slave" as follows:
3c 00 4b 46 ff ff 0d 10 16 : crc=16 YES
3c 00 4b 46 ff ff 0d 10 16 t=29937
From the above, I only need to extract the integer number 29937, and my code is:
public static void main(String[] args) throws IOException {
// create token1
String token1 = "";
// create Scanner inFile1
@SuppressWarnings("resource")
// detect delimiter "," and " "
Scanner w1Slave = new Scanner(new File("C:/Users/Hamid/Desktop/w1_slave.txt")).useDelimiter(",| ");
List<String> temps = new ArrayList<String>();
// while loop
while (w1Slave.hasNext()) {
// find next line
token1 = w1Slave.next();
temps.add(token1);
}
w1Slave.close();
String[] tempsArray = temps.toArray(new String[0]);
int tempsArrayLength = tempsArray.length - 1;
System.out.println(tempsArray[tempsArrayLength]);
The output is t=29937. Could you tell me how I can extract just 29937 as an integer or double number, please?