From String array to int array throwing ','and null from text file
hey every one
i developed a code to read a text file and put the integers in array but i had a problem to convert the string array to int array throwing any thing else except the imts ,
public static void main (String[] args) throws FileNotFoundException, IndexOutOfBoundsException , IOException, Exception {
System.out.println("Enter a filepath to copy from, and one to copy to.");
Scanner in = new Scanner(System.in);
String a=in.next();
File f = new File (a);
FileInputStream FF = new FileInputStream(f);
BufferedReader br = new BufferedReader(new InputStreamReader(FF));
BufferedReader brr = new BufferedReader(new FileReader(a));
String line;
int linecount =0 ;
while ((line = brr.readLine()) != null) {
linecount++;
}
Re: From String array to int array throwing ','and null from text file
thanks for responding
this is what i get when i use parseint
Enter a filepath to copy from, and one to copy to.
C:\Users\F.A.M\Desktop\GGGGGGGGG\tr.txt
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:470)
at java.lang.Integer.parseInt(Integer.java:499)
at s.Read.convertStringArraytoIntArray(Read.java:20)
at s.Read.main(Read.java:64)
Java Result: 1
BUILD SUCCESSFUL (total time: 7 seconds)
===============
when i use a char array to move every strings to like
Re: From String array to int array throwing ','and null from text file
the problem is that netbeans wont let me copy line numbers and i put an index value index value
and thats what i get
Enter a filepath to copy from, and one to copy to.
C:\Users\F.A.M\Desktop\GGGGGGGGG\tr.txt
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at s.Read.main(Read.java:68)
Java Result: 1
BUILD SUCCESSFUL (total time: 50 seconds)
code
char [] dd = new char [500] ;
char [] d = new char [500];
int t=0;
Re: From String array to int array throwing ','and null from text file
i should delete line 69 that cause the error otherwise it wont print any thing
this the code after deleting the error line (t will not change == remain 0)
Bookmarks