0

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.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by tong1
0

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);
0

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);

Edited by tong1: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.