can't have a file larger than 10*10 characters

PacsiTo

New Member
what makes it only be able to input 10*10 text files\[code\]package game;import java.io.*;import java.util.*;public class Level {static public void main(String[] args) throws IOException { File f = new File("Data1.txt"); int[][] m = Map(f); for (int x = 0; x < m.length; x++) { for (int y = 0; y < m[x].length; y++) { System.out.print(m[x][y]); } System.out.println(); }}public static int[][] Map(File f) throws IOException { ArrayList line = new ArrayList(); BufferedReader br = new BufferedReader(new FileReader(f)); String s = null; while ((s = br.readLine()) != null) { line.add(s); } int[][] map = new int[line.size()][]; for (int i = 0; i < map.length; i++) { s = (String) line.get(i); StringTokenizer st = new StringTokenizer(s, " "); int[] arr = new int[st.countTokens()]; for (int j = 0; j < arr.length; j++) { arr[j] = Integer.parseInt(st.nextToken()); } map = arr; } return map;}}\[/code\]if i put in a text file that is 10*10 or less characters it worksotherwise it comes out with a numberformatexception fixedpackage game;\[code\]import java.io.*;import java.util.*;public class Level { static public void main(String[] args) throws IOException { File f = new File("Data1.txt"); int[][] m = Map(f); for (int x = 0; x < m.length; x++) { for (int y = 0; y < m[x].length; y++) { System.out.print(m[x][y]); } System.out.println(); } } public static int[][] Map(File f) throws IOException { ArrayList line = new ArrayList(); BufferedReader br = new BufferedReader(new FileReader(f)); String s = null; while ((s = br.readLine()) != null) { line.add(s); } int[][] map = new int[line.size()][]; for (int i = 0; i < map.length; i++) { s = (String) line.get(i); char[] m = s.toCharArray(); String[] n = new String[m.length]; for (int t = 0; t<m.length;t++) { n[t] = ""+m[t]; } int[] arr = new int[m.length]; for (int j = 0; j < arr.length; j++) { arr[j] = Integer.parseInt(n[j]); } map = arr; } return map; }}\[/code\]
 
Back
Top