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


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

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

Date 2011-02-11 18:03 +0200
From Donkey Hottie <donkey@fredriksson.dy.fi>
Newsgroups comp.lang.java.programmer
Subject Re: Shortest way to read all lines (one by one) from a text file?
References <4d54f158$0$6975$9b4e6d93@newsspool4.arcor-online.net>
Message-ID <s73g28-tga.ln1@lancaster.fredriksson.dy.fi> (permalink)
Organization NBL Networks Oy

Show all headers | View raw


On 11.2.2011 10:20, Robin Wenger wrote:
> Ok, I know in general a way to read text lines ony-by-one from a file into a string variable.
> But I miss somehow a short one-liner like:
> 
> 
> foreach(String currentline : file("D:\test\myfile.txt")) {
>    ....
>    }
>    
> Is there something like this in Java?
> What would be the shortest way otherwise?
>            
> Robin
> 

public interface MySimpleUtilities
{
    public static String[] readWholeFile(String filename)
       throws IOException ;
}

Why is it so hard to implement own tools for ones liking?

-- 

Your temporary financial embarrassment will be relieved in a surprising
manner.

Back to comp.lang.java.programmer | Previous | Next | Find similar


Thread

Re: Shortest way to read all lines (one by one) from a text file? Donkey Hottie <donkey@fredriksson.dy.fi> - 2011-02-11 18:03 +0200

csiph-web