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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -