/** * Writes the specified index to the associated output stream. This may be called multiple times in order * to write multiple indexes. The default version of index file is used. * * @param index the index to write to the stream * @return the number of bytes written to the stream * @throws IOException if the underlying stream fails */ public int write(Index index) throws IOException { return write(index, IndexWriterV2.MAX_VERSION); }
private Result indexDirectory(File source, Indexer indexer) throws FileNotFoundException, IOException { File outputFile = this.outputFile; scanFile(source, indexer); if (modify) { new File(source, "META-INF").mkdirs(); outputFile = new File(source, "META-INF/jandex.idx"); } if (outputFile == null) { outputFile = new File(source.getName().replace('.', '-') + ".idx"); } FileOutputStream out = new FileOutputStream(outputFile); IndexWriter writer = new IndexWriter(out); try { Index index = indexer.complete(); int bytes = writer.write(index); return new Result(index, outputFile.getPath(), bytes, outputFile); } finally { out.flush(); out.close(); } }
/** * Writes the specified index to the associated output stream. This may be called multiple times in order * to write multiple indexes. * * @param index the index to write to the stream * @param version the index file version * @return the number of bytes written to the stream * @throws IOException if any i/o error occurs */ public int write(Index index, int version) throws IOException { IndexWriterImpl writer = getWriter(version); if (writer == null) { throw new UnsupportedVersion("Version: " + version); } return writer.write(index, version); }
IndexWriter writer = new IndexWriter(out); Index index = indexer.complete(); writer.write(index); return index; } catch (IOException e) {
IndexWriter writer = new IndexWriter(out); Index index = indexer.complete(); int bytes = writer.write(index);
/** * Writes the specified index to the associated output stream. This may be called multiple times in order * to write multiple indexes. * * @param index the index to write to the stream * @param version the index file version * @return the number of bytes written to the stream * @throws IOException if any i/o error occurs */ @Deprecated public int write(Index index, byte version) throws IOException { return this.write(index, version & 0xFF); }
IndexWriter writer = new IndexWriter(data); writer.write(index);