嗨我是新手编程,需要为我的学校项目提取数据。数据来自Arduino设备,该设备发送的数据看起来像这样。在netbeans中分割尖括号之间的传入数据
<call_sign>IVV-HAM</call_sign>
<mission_call>ARP</mission_call>
<absolute_time>13:13:13</absolute_time>
<elapsed_time>43</elapsed_time>
<imu_accel_x>240</imu_accel_x>
<imu_accel_y>196</imu_accel_y>
<imu_accel_z>62</imu_accel_z>
<imu_gyro_x>599</imu_gyro_x>
<imu_gyro_y>1013</imu_gyro_y>
<imu_gyro_z>215</imu_gyro_z>
<imu_mag_x>402</imu_mag_x>
<imu_mag_y>495</imu_mag_y>
<imu_mag_z>447</imu_mag_z>
<imu_temp>453</imu_temp>
我需要摆脱前三行,然后发送剩余的代码进行绘图。我试图划分和分割尖括号但我知道怎么做似乎工作。 任何帮助意见或建议我可以找到答案(我已经在这里看了一天已经),将不胜感激谢谢。
public void run(){
//create a new Scanner and connect it to the Serial Port
input = new Scanner(connectedPort.getInputStream());
//HERE I tried to use input.useDelimiter("></")
// I also tried to split by creating a string.split but
// it did not work either.
//loop indefinitely until you get data from the Serial Port
while(input.hasNextLine()){
//get line of text from serial port
String line = input.nextLine();
//dump the raw data to the output text area
//taRawOutput.append(Integer.toString(number)+'\n');
textArea_RawData.append(line+"\n");
}//end of loop
//close the scanner object reading from the serial port
input.close();
}//end of methd run()
};//end of inner class definition
//start the thread that was just defined running
thread.start();
}catch(IOException e){
JOptionPane.showMessageDialog(this, e.getMessage());
}//end of catch block
}
我试着编辑问题来显示我做了什么。
请告诉我们你试过的东西 –
PS看起来像XML –
“新扫描仪”之后,我尝试使用“input.useDelimiter(”>“)”但不起作用的分隔符我删除了代码。 –