137.132.124.30 writes:
How do I extract integers from a sequential txt file of the following format : 110 120 130 140...I've tried readInt()..readByte()....every possible methods in DataInputStream...but all get is some funny numbers...not 110, 120...Anyone can help?
Jay
152.205.22.243 writes:
Warning: Untested suggestions below.
If I were attacking the problem, I'd use a loop as so:
String strToParse;
char chAdd = ''; // empty value
while (chAdd != ' ') // a blank space (ASCII 32)
{
strToParse = strToParse + chAdd;
chAdd = (char) disTxtFile.readByte();
}
try
{
int iNumFromFile = Integer.valueOf(strToParse);
}
catch (NumberFormatException nfe)
{
// PANIC!!! ... or do something
}
// do something with "iNumFromFile"
MikeD