hello
I have a problem with my code...
here's the complete lines of errors:
may be some one know what it means or what can I do to fix it..
I have a problem with my code...
here's the complete lines of errors:
Code:
Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at hakbaz.Short.reader(Short.java:45) at hakbaz.Main.main(Main.java:11)
Code:
package hakbaz; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; public class Short { public static int [][]road; public static int x; public static int n; public static int t; public void reader() { Scanner sc; String str; int i; File file = new File("data.TXT"); FileInputStream fis = null; BufferedInputStream bis = null; DataInputStream dis = null; try { fis = new FileInputStream(file); bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); str = dis.readLine(); sc = new Scanner(str); n=sc.nextInt(); str = dis.readLine(); sc = new Scanner(str); x=sc.nextInt(); str = dis.readLine(); sc = new Scanner(str); t=sc.nextInt(); dis.readLine(); i=0; int col=(2*x)+3; road = new int[n][col]; while (dis.available() != 0) { str = dis.readLine(); sc = new Scanner(str); for (int j=0; j<col; j++) road[i][j]=sc.nextInt(); i++; } fis.close(); bis.close(); dis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } package hakbaz; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Short way= new Short(); way.reader(); System.out.println(Short.n+" "+Short.road[0][2]); } }
Comment