I want to get a specific String from a Text file.
E.g i only want to have the indicated part (3rd Line) to be saved in new File
19:22:08.999 T:5804 NOTICE: Aero is enabled
19:22:08.999 T:5804 NOTICE: special://xbmc/ is mapped to: C:\Program Files (x86)\Kodi
19:22:08.999 T:5804 NOTICE: key://xbmcbin/ is mapped to: C:\Program Files (x86)\Kodi
I want this part -----> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:22:08.999 T:5804 NOTICE: special://xbmcbinaddons/ is mapped to: C:\Program Files (x86)\Kodi/addons
My code:
public static void main(String[] args) throws IOException {
ArrayList<String> result = new ArrayList<>();
Scanner s = null;
try {
s = new Scanner(new BufferedReader(new FileReader("C:/test.txt")));
while (s.hasNextLine()) {
result.add(s.nextLine());
}
} finally {
if (s != null){
s.close();
}
} System.out.println(result);
}
I have everything saved in a ArrayList but how can i now
- Save only one element of this ArrayList
- Save only part of a line (the bold one) in a variable or a new file.
EDIT I solved everything Thank you very much for your help espacially @dustytrash