com.unboundid.util
Class DNFileReader

java.lang.Object
  extended by com.unboundid.util.DNFileReader
All Implemented Interfaces:
java.io.Closeable

@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class DNFileReader
extends java.lang.Object
implements java.io.Closeable

This class provides a mechanism for reading DNs from a file. The file is expected to have one DN per line. Blank lines and lines beginning with the octothorpe (#) character will be ignored. Lines may contain just the raw DN, or they may start with "dn:" followed by an optional space and the DN, or "dn::" followed by an optional space and the base64-encoded representation of the DN.


Constructor Summary
DNFileReader(java.io.File dnFile)
          Creates a new DN file reader that will read from the specified file.
DNFileReader(java.lang.String path)
          Creates a new DN file reader that will read from the file with the specified path.
 
Method Summary
 void close()
          Closes this DN file reader.
 DN readDN()
          Reads the next DN from the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DNFileReader

public DNFileReader(java.lang.String path)
             throws java.io.IOException
Creates a new DN file reader that will read from the file with the specified path.

Parameters:
path - The path to the file to be read. It must not be null and the file must exist.
Throws:
java.io.IOException - If a problem is encountered while opening the file for reading.

DNFileReader

public DNFileReader(java.io.File dnFile)
             throws java.io.IOException
Creates a new DN file reader that will read from the specified file.

Parameters:
dnFile - The file to be read. It must not be null and the file must exist.
Throws:
java.io.IOException - If a problem is encountered while opening the file for reading.
Method Detail

readDN

public DN readDN()
          throws java.io.IOException,
                 LDAPException
Reads the next DN from the file.

Returns:
The DN read from the file, or null if there are no more DNs to be read.
Throws:
java.io.IOException - If a problem is encountered while trying to read from the file.
LDAPException - If data read from the file can't be parsed as a DN.

close

public void close()
           throws java.io.IOException
Closes this DN file reader.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException - If a problem is encountered while closing the reader.