Код: Выделить всё
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String words = jTextPane1.getText();
try {
new button4().keyword(words);
} catch (IOException ex) {
}
}
public boolean keyword (String keyword) throws FileNotFoundException, IOException {
//search with a keyword
File path = new File("C:\\Users\\nicol\\Desktop\\Database\\Doctor");
File [] files = path.listFiles();
ArrayList arr = new ArrayList();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()){
try {
BufferedReader buff=new BufferedReader(new FileReader(files[i]));
String s;
Arrays.sort(files);
while((s=buff.readLine())!=null){
if(s.trim().contains(keyword)){
String n = files[i].getName().toString();
BufferedReader br = new BufferedReader(new FileReader(files[i]));
String line;
while ((line = br.readLine()) != null) {
arr.add(line);
}
String con = arr.toString();
jTextArea1.setText(con);
}
}
buff.close();
} catch (Exception e){
e.printStackTrace();
}
}
}
return false;
}
Надеюсь, кто-нибудь сможет помочь
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-input-by