How to get scanner to read pipe delimited txt file in java -


i've been trying scanner read , sort pipe delimited text file using delimiter \|but cant seem sort or display reformatted file. when open filechooser throws , error when try import scanner. data in txt file mixture of strings , ints

scanner scanner = new scanner("/n"); scanner.usedelimiter(pattern.compile("[|\n]")); jtable jt = new jtable(); list<integer> list = new arraylist<>();     system.out.println(scanner.nextint()); system.out.println(scanner.nextint()); file readfile;     //creates file variable      jfilechooser jfilechooser_open = new jfilechooser();     int option = jfilechooser_open.showopendialog(this);     readfile = jfilechooser_open.getselectedfile();//instantiates file ,  gets selected file jfilechooser      string line;     try (filereader instream = new filereader(readfile); bufferedreader     inbuffer = new bufferedreader(instream)) {         //create variable line              while ((line = inbuffer.readline()) != -1 ) { while (scanner.hasnext()) { list.add(line); list.add(scanner.nextint());  } system.out.println(list);          }     }   catch (ioexception ex) {  logger.getlogger(newjframe.class.getname()).log(level.severe,null, ex);         } 

also want newly formatted string displayed in table or text area. if guys me print console, appreciate it.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -