Jump to content
  • Advertisement
Sign in to follow this  
darkchrono4

[java] Resetting the Scanner

This topic is 4723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Looking at the API docs, there doesn't appear to be one.
--But why would you want to? You should probably save whatever it is you need when the Scanner arrives at something you'll need later. Are you working with huge files or something?

Share this post


Link to post
Share on other sites
Reading in a matrix of unknown size. First I use .nextLine() to get the number of rows, then .nextInt() for total items (divide that by rows to get columns), then create the array and read in the matrix. Its just kind of a pain to open and close the file so many times.

Share this post


Link to post
Share on other sites
couldn't you do something like:
InputStream fileInputStream = new FileInputStream(myFile);
Scanner aScanner = new Scanner(fileInputStream);
// ... do your stuff
fileInputStream.reset();
// ... read in matrix
or wouldn't that work?

Share this post


Link to post
Share on other sites
I'll give it a shot.

It works, but today the specs got changed so the size of the matrix is in the text file.

[Edited by - darkchrono4 on June 16, 2005 12:31:00 PM]

Share this post


Link to post
Share on other sites
What Funkapotamus suggested is how I'd probably do it, actually I think it's the easier (and obviously faster) way to do what you want, rather than doing some kind of random access of a file on disk.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!