I have a question about scanner please;I working at a small company; we have a software; it generate a big text file; and we must get some useful information from it ; i want write a simple application with java for saving time; could you please guide me ?
for example i want this output ;
Output
RFID : 25
BLUID : 562
WifiID : 2610
RFID : 33
RFID Count : 2
and for example ;this is my Text file, because each generated file with our software has 14000 lines 🙂
--------------------------
AAAAAAAAAAAA;RFID=25;
BBBB;BBBBBBBB;BBBBBBBBBB;
CCCCC;fffdsfdsfdfsd;BLUID=562;dfsdfsf;
fgfdgdf;terter;fdgfdgtryt;
trtretrre;WifiID=2610;trterytuytutyu;
zxzxzxzxz;popopopwwepp;RFID:33;aasasds…
gfdgfgfd;gfdgfdgfd;fdgfgfgfd;
I test it with this source code but i can’t handle it;
Scanner scanner = new Scanner("i:\1.txt");
scanner.findInLine("RFID=");
if (scanner.hasNext())
System.out.println(scanner.next());
else
System.out.println("Error!");
please help me ;
Thanks a lot …
Well your suggested source would not do what you want. Scanner breaks up input using a delimiter. The default delimiter is whitespace (spaces, tabs or newlines). Scanner.hasNext() simply tells you if there is a new whitespace delimted token. Scanner.next() simply returns that token. Note that none of these are effected by Scanner.findInLine(pattern) as all it does is search the current line for the provided pattern.
Maybe something like this (I have not tested this):
I would recommend you forget about using scanner and just use a BufferedReader and a couple of Pattern objects as that method is more flexible for what you want to do.