Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25850

Re: Shortest way to read all lines (one by one) from a text file?

Newsgroups comp.lang.java.programmer
Subject Re: Shortest way to read all lines (one by one) from a text file?
From Real Gagnon <realgag+usenet@geocities.com>
References <4d54f158$0$6975$9b4e6d93@newsspool4.arcor-online.net> <c_CdnSN0wqBIZ8nQnZ2dnUVZ_jqdnZ2d@posted.palinacquisition> <ij3bb4$eal$1@news.albasani.net>
Message-ID <Xns9E89B2DE6294rgagnoncom@69.16.186.8> (permalink)
Organization EasyNews, UseNet made Easy!
Date 2011-02-11 22:34 +0000

Show all headers | View raw


Lew <noone@lewscanon.com> wrote in news:ij3bb4$eal$1@news.albasani.net:

> The Scanner class also provides compact ways to do this, although it's
> field oriented rather than line oriented. 

True but it's possible to use the EOF as the delimiter

   Scanner scanner = 
      new Scanner(new File("c:/temp/text.txt")).useDelimiter("\\Z");
    String contents = scanner.next();

BYe.


-- 
Real Gagnon  from  Quebec, Canada
* Java, Javascript, VBScript or PowerBuilder snippets
* http://rgagnon.com/howto.html
* http://rgagnon.com/bigindex.html

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Re: Shortest way to read all lines (one by one) from a text file? Lew <noone@lewscanon.com> - 2011-02-11 07:51 -0500
  Re: Shortest way to read all lines (one by one) from a text file? Real Gagnon <realgag+usenet@geocities.com> - 2011-02-11 22:34 +0000

csiph-web