-
May 24th, 2011, 01:33 PM
#1
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 ,
this is the content of the text file
5
1,10
8,10
10,8
7,4
3,1
0,1,10
1,2,5
2,3,25
0,3,3
3,4,8
this my code
import java.io.*;
import java.util.*;
*
public class Read {
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++;
}
char [] k = null;
String [] s = null ;
s = new String[50];
int [] dd = null ;
char [] d = null;
for (int j = 0; j < linecount; j++){
s[j] = br.readLine();
}
FF.close();
}
}
==========================================================
i tried with many ways to convert that string array to int array so the int array well be like
{5,1,10,8,10,10,8,7,4,3,1,0,1,10,1,2,5,2,3,25,0,3,3,3,4,8}
i used cahrtat method and parseint method but it doesnt work
Can any one help me with this
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|