private synchronized ChemComp getFromZip(String recordName) {
		ChemComp cc = null;
		if (!m_zipFile.toFile().exists()) return cc;
		final String filename = "chemcomp/" + recordName+".cif.gz";

		// try with resources block to read from the filesystem.
		try (FileSystem fs = FileSystems.newFileSystem(m_zipFile, null)) {
			Path cif = fs.getPath(filename);

			if (Files.exists(cif)) {
				final InputStream zipStream = Files.newInputStream(cif);
				final InputStream inputStream = new GZIPInputStream(zipStream);
				s_logger.debug("reading " + recordName + " from " + m_zipFile);
				final MMcifParser parser = new SimpleMMcifParser();
				final ChemCompConsumer consumer = new ChemCompConsumer();
				parser.addMMcifConsumer(consumer);
				parser.parse(inputStream);
				inputStream.close();

				final ChemicalComponentDictionary dict = consumer.getDictionary();
				cc = dict.getChemComp(recordName);
			}
		} catch (IOException e) {
			s_logger.error("Unable to read from zip file : " + e.getMessage());
		}

		return cc;
	}
private synchronized ChemComp getFromZip ( String recordName ) { ChemComp cc = null ; if ( ! m_zipFile . toFile ( ) . exists ( ) ) return cc ; final String filename = "chemcomp/" + recordName + ".cif.gz" ; try ( FileSystem fs = FileSystems . newFileSystem ( m_zipFile , null ) ) { Path cif = fs . getPath ( filename ) ; if ( Files . exists ( cif ) ) { final InputStream zipStream = Files . newInputStream ( cif ) ; final InputStream inputStream = new GZIPInputStream ( zipStream ) ; s_logger . debug ( "reading " + recordName + " from " + m_zipFile ) ; final MMcifParser parser = new SimpleMMcifParser ( ) ; final ChemCompConsumer consumer = new ChemCompConsumer ( ) ; parser . addMMcifConsumer ( consumer ) ; parser . parse ( inputStream ) ; inputStream . close ( ) ; final ChemicalComponentDictionary dict = consumer . getDictionary ( ) ; cc = dict . getChemComp ( recordName ) ; } } catch ( IOException e ) { s_logger . error ( "Unable to read from zip file : " + e . getMessage ( ) ) ; } return cc ; }
This is synchronized, along with addToFileSystem to prevent simulatenous reading/writing.
@param recordName to find in zipfile.
@return ChemComp if found or null if missing.