InputMismatchException Filereading FileWriting -



InputMismatchException Filereading FileWriting -

so yeah here problem. inputmismatchexception @ line of int count. how prepare issue ? 1 rule must not touch code line 32 - 100+.

package main;

import java.util.*; import java.io.*; public class main { public static void main(string[] args) { scanner in = new scanner(system.in); int pick =0; //menu system.out.println("pick option"); system.out.println("1. add"); system.out.println("2. modify"); system.out.println("3. delete"); system.out.println("4. view"); system.out.print("enter #: "); pick = in.nextint(); system.getproperty("line.separator"); if(pick == 1) { string info = "database.txt"; seek { filewriter filewriter = new filewriter(data); // wrap filewriter in bufferedwriter. bufferedwriter bufferedwriter = new bufferedwriter(filewriter); // note write() not automatically // append newline character. string fname = in.next(); string lname = in.next(); string city = in.next(); string id = in.next(); bufferedwriter.write(fname); bufferedwriter.newline(); bufferedwriter.write(lname); bufferedwriter.newline(); bufferedwriter.write(city); bufferedwriter.newline(); bufferedwriter.write(id); // close files. bufferedwriter.close(); } grab (ioexception ex) { system.out.println("cannot write !"); } } seek { scanner input = new scanner(new filereader("database.txt")); // read how many records there int count = input.nextint(); // remove excess newline input.nextline(); for(int = 0; < count; i++) { string fname = input.nextline(); string lname = input.nextline(); string city = input.nextline(); string id = input.nextline(); system.out.printf("student #%d\n", i+1); system.out.println(fname); system.out.println(lname); system.out.println(city); system.out.println(id); system.out.println(); } input.close(); } grab (filenotfoundexception e) { system.out.println("file not found!"); } } }

please guide me right way accomplish objective.

inputmismatchexception

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -