Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33923
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | egarrulo <egarrulo@gmail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Libraries for sysadmins? |
| Date | Fri, 4 Mar 2016 20:30:17 +0100 |
| Lines | 52 |
| Message-ID | <dju62bFf4ouU1@mid.individual.net> (permalink) |
| References | <2cec6af2-9636-4a2a-8849-b01286c0814c@googlegroups.com> <sysadmins-20160304161143@ram.dialup.fu-berlin.de> <djttl0Fct5hU1@mid.individual.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net 20LWNP1V4Z6NdIhSxisweQtx0QrEWQIKD0iP4vpLibCBHiCzmK |
| Cancel-Lock | sha1:Bt97RDo2KSQKh0w3Qu8XDGWrI3U= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
| In-Reply-To | <djttl0Fct5hU1@mid.individual.net> |
| Xref | csiph.com comp.lang.java.programmer:33923 |
Show key headers only | View raw
On 04/03/16 18:06, Robert Klemme wrote:
>
> I would look into using JRuby, maybe also look into Groovy (not sure how
> much alive the latter is these days).
>
> On 04.03.2016 16:13, Stefan Ram wrote:
>> Elena <egarrulo@gmail.com> writes:
>>> processing text files line by line
>>
>> Writing lines to a text file:
>>
>> new java.io.FileWriter( "c:\\example.txt" ).
>> append( "alpha\n" ).close();
>
> In (J)Ruby:
>
> File.open("example.txt", "a") {|io| io.puts "alpha"}
>
>> Reading a text file line by line (not tested):
>>
>> final java.util.Scanner scanner
>> = new java.util.Scanner( new java.io.File( "file.txt" ));
>> while( scanner.hasNextLine() )
>> { final java.lang.String line = scanner.nextLine();
>
> In (J)Ruby:
>
> File.foreach "file.txt" do |line|
> # whatever
> end
>
>>> filtering collections
>>
>> (not tested):
>>
>> java.util.Arrays.asList( 1, 2, 3 ).stream().
>> filter( x -> "x >= 2 )
>
> Again, in (J)Ruby:
>
> [1,2,3].select {|x| x >= 2}
>
> (Not exactly the same, but can easily be made to if need be.)
>
> Kind regards
>
> robert
Wow! The Java version is remarkably concise and compares favourably
with the Ruby version. Where could I find more of these examples of
"short and sweet" Java? In the "Java Cookbook" (3rd edition) by Ian F.
Darwin, maybe?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Libraries for sysadmins? Elena <egarrulo@gmail.com> - 2016-03-04 03:33 -0800
Re: Libraries for sysadmins? Martin Gregorie <martin@address-in-sig.invalid> - 2016-03-04 11:44 +0000
Re: Libraries for sysadmins? egarrulo <egarrulo@gmail.com> - 2016-03-04 12:56 +0100
Re: Libraries for sysadmins? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-03-04 07:43 -0500
Re: Libraries for sysadmins? Robert Klemme <shortcutter@googlemail.com> - 2016-03-04 18:06 +0100
Re: Libraries for sysadmins? egarrulo <egarrulo@gmail.com> - 2016-03-04 20:30 +0100
Random permutations [was Re: Libraries for sysadmins?] Sebastian <news@seyweiler.dyndns.org> - 2016-03-05 00:56 +0100
Re: Random permutations [was Re: Libraries for sysadmins?] Robert Klemme <shortcutter@googlemail.com> - 2016-03-05 12:11 +0100
Re: Random permutations [was Re: Libraries for sysadmins?] Sebastian <news@seyweiler.dyndns.org> - 2016-03-05 16:41 +0100
Re: Random permutations [was Re: Libraries for sysadmins?] Brixomatic <brixomatic@yahoo.com> - 2016-03-05 19:20 +0100
Re: Random permutations [was Re: Libraries for sysadmins?] Andreas Leitgeb <avl@logic.at> - 2016-03-05 18:46 +0000
Re: Random permutations [was Re: Libraries for sysadmins?] Brixomatic <brixomatic@yahoo.com> - 2016-03-15 19:22 +0100
Re: Random permutations [was Re: Libraries for sysadmins?] Andreas Leitgeb <avl@logic.at> - 2016-03-15 22:30 +0000
Re: Random permutations [was Re: Libraries for sysadmins?] Andreas Leitgeb <avl@logic.at> - 2016-03-05 18:30 +0000
Re: Random permutations [was Re: Libraries for sysadmins?] Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-03-05 13:46 -0500
Re: Random permutations [was Re: Libraries for sysadmins?] Andreas Leitgeb <avl@logic.at> - 2016-03-05 19:40 +0000
Re: Libraries for sysadmins? Robert Klemme <shortcutter@googlemail.com> - 2016-03-05 12:10 +0100
Re: Libraries for sysadmins? Arne Vajhøj <arne@vajhoej.dk> - 2016-03-04 21:42 -0500
Re: Libraries for sysadmins? Arne Vajhøj <arne@vajhoej.dk> - 2016-03-04 21:48 -0500
csiph-web