directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eric tse <hfe...@gmail.com>
Subject Re: parseLdifFile Run out of memory
Date Wed, 29 Jan 2014 23:08:20 GMT
Thanks it works like a charm. I am going to run it with larger data set now
:)


On Wed, Jan 29, 2014 at 4:00 PM, eric tse <hfetse@gmail.com> wrote:

> Thanks will try now :)
>
>
> On Wed, Jan 29, 2014 at 3:53 PM, Stefan Seelmann <mail@stefan-seelmann.de>wrote:
>
>> On 01/29/2014 06:38 PM, eric tse wrote:
>>
>> > Can you point me out any simple sample java code that demonstrate the
>> most
>> > basic concept of using "iterate on the reader using reader.next()"?
>>
>> LdifReader implements java.lang.Iteratable, so you can do the following
>> (omitting resource handling):
>>
>>
>>     File file = new File("/path/to/your/file.ldif" );
>>     LdifReader ldifReader = new LdifReader( file );
>>     Iterator<LdifEntry> iterator = ldifReader.iterator();
>>     while(iterator.hasNext()) {
>>         LdifEntry ldifEntry = iterator.next();
>>         System.out.println(ldifEntry);
>>     }
>>     ldifReader.close();
>>
>>
>> Or much nicer using Java 7 try-with-resource statement and foreach loop:
>>
>>
>>     try ( LdifReader ldifReader = new LdifReader( file ) )
>>     {
>>         for ( LdifEntry ldifEntry : ldifReader )
>>         {
>>             System.out.println( ldifEntry );
>>         }
>>     }
>>
>>
>> HTH,
>> Stefan
>>
>>
>

Mime
View raw message