Hi, I want to know to rows and columns of numbers from a text file.
I do not want to read it as a string, but one number (including numbers with decimal) by itself. I tried using FileInputStream and DataInputStream, but I'm not really good at it. I don't know how to not read it as a double, and not a string.

Recommended Answers

All 2 Replies

What might also work then in that case, is maybe just converting the string that you're getting to an int or what ever you want? As in:

myInt = Integer.parseInt(theStringThatYoureGetting);

Following Dean_Grobler's suggestion you may read each number as a string s, and then convert s into a decimal number in the type of double by the following line of code:

double d = Double.parseDouble(s);

or convert s into a decimal number in the type of float:

float f = Float.parseFloat(s);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.