我已经制作了一个程序,将输入的数据保存在文本字段中。它的保存技术是这样的
data0 = student number
data1 = name
data2 = section
data3 = cp
data4 = email
data5 = address
在保存的文件中:
data0 | data1 | data2 | data3 | data4 | data5
data0 | data1 | data2 | data3 | data4 | data5
data0 | data1 | data2 | data3 | data4 | data5
data0 | data1 | data2 | data3 | data4 | data5
data0 | data1 | data2 | data3 | data4 | data5
data0 是唯一的,如果我搜索 12293,这是我用来搜索学生编号“data0”的代码
data0 | data1 | data2 | data3 | data4 | data5
data0 | data1 | data2 | data3 | data4 | data5
12293 | blahh | blehh | blihh | blohh | bluhh
data0 | data1 | data2 | data3 | data4 | data5
并且第 3 行有一个匹配项,blah,blehh,blihh,blohh,bluhh 必须打印在不同的 textarea 中
但我不知道如何切片 data1|data2|data3|data4|data5| 当搜索匹配时进入数组
这是我的代码:
import java.io.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Jfetizanan
*/
public class DATALOAD {
/**
* @param args the command line arguments
* @throws UnsupportedEncodingException
* @throws FileNotFoundException
* @throws IOException
*/
public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, IOException {
try{
FileInputStream fstream = new FileInputStream("data.dat");
try (DataInputStream in = new DataInputStream(fstream)) {
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
if (strLine.startsWith("JFETZ")){
System.out.println("Data Found");
}
else
{System.out.println("Nothing Found in this line");}
}
}
}catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}