lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ganyo <scott.ga...@eTapestry.com>
Subject RE: Converting a Directory to a RAMDirectory
Date Thu, 17 Oct 2002 19:02:20 GMT
+1

> -----Original Message-----
> From: Eric Isakson [mailto:Eric.Isakson@sas.com]
> Sent: Thursday, October 17, 2002 1:43 PM
> To: Lucene Developers List
> Subject: RE: Converting a Directory to a RAMDirectory
> 
> 
> Why not add this code to a RAMDirectory constructor like:
> 
> 	public RAMDirectory(Directory d) throws IOException {
> 		this();
> 		final String[] ar = d.list();
> 		for (int i = 0; i < ar.length; i++) {
> 			// make place on ram disk
> 			OutputStream os = createFile(ar[i]);
> 			// read current file
> 			InputStream is = d.openFile(ar[i]);
> 			// and copy to ram disk
> 			int len = (int) is.length();
> 			byte[] buf = new byte[len];
> 			is.readBytes(buf, 0, len);
> 			os.writeBytes(buf, len);
> 			// graceful cleanup
> 			is.close();
> 			os.close();
> 		}
> 	}
> 
> --
> Eric D. Isakson        SAS Institute Inc.
> Application Developer  SAS Campus Drive
> XML Technologies       Cary, NC 27513
> (919) 531-3639         http://www.sas.com
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message