View Single Post
  #7 (permalink)  
Old 09-11-2008, 01:20 AM
2potatocakes 2potatocakes is offline
Member
 
Join Date: Sep 2008
Posts: 18
2potatocakes is on a distinguished road
sorry, I was being a little too basic huh..?
Thanks to all the guys that wrote something constructive on here

But it was my fault for not asking the question correctly. It was more like half of a question. Here's my dilemna:

I have a txt file filled with hundreds and thousands of digits and no spaces.

I can read from the text file no probs and have been using get chars to select the digits I need. But I can't figure out how to convert the newly formed character string into an integer. It won't accept Integer.parseInt ..well it compiles ok, but always throws up an error when it runs.

Am I doing something blatantly obvious or is their a trick to converting either a char array or a string from a text file into an integer?

I'm just using the following lines to test if it works.

String nmbrs = contents.toString();
System.out.println(nmbrs);

// char[] textArray = new char[3];
// nmbrs.getChars(9, 12, textArray, 0);
// System.out.println(textArray);

int difx;
difx=Integer.parseInt(nmbrs);
System.out.println(difx+1);

Can anyone see what I'm doing wrong?

Again, thanks for the help guys
Reply With Quote