The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

BufferedReader might help

Posted by Hiran on January 15, 2002 at 10:22 PM

Danny, you could try using a BufferedReader object. It wraps around another input reader (such as InputStreamReader, or FileReader). For more info, see Sun's Java Documentation. BufferedReader has a method called readLine() that you would probably use. It reads a line of text and returns it as a string. Then you could parse the string, and extract the info you want, and convert it to integer to store in your array. (I know there's a way to convert from String to int, but I'm not sure how). Anyway, hope this helps.
Hiran

> Hi experts ! This shozuld be an easy question :
> there is a file which contains numbers like 21 12 54 6 8 .. I have to take portions of 6 and program a constructor which initialises an object with the information of the file.

> class numberlist
> {
> private int numberlist[]=new int[6];

> // Constructors
> for (i=1;i<=6;i++)
> {public numberlist[i]= ** ? **
> }
> }

> ** ? ** -> How to put the information from the file "name.txt" into numberlist[i]

> Thanks in advance






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us