Get input stream for resource in zip file.

@param zipFile zip file
@param resourcePath path to resource
@return input stream for resource or null if not found or directory
@throws IOException if there is any transport error
971280
@Nullable
  public static InputStream findInputStreamForResource(@Nonnull final ZipFile zipFile, @Nonnull final String resourcePath) throws IOException {
    final ZipEntry entry = zipFile.getEntry(resourcePath);

    InputStream result = null;

    if (entry != null && !entry.isDirectory()) {
      result = zipFile.getInputStream(entry);
    }

    return result;
  }
1059200
@Override
	public Set<InputStream> getResourcesAsStream(final String path) throws IOException
	{
		// First, try the path as specified
		final Set<InputStream> streams = inner.getResourcesAsStream(path);

		// If no results were found and the path was absolute, retry without the leading slash
		if ((streams == null || streams.isEmpty()) && !path.isEmpty() && path.charAt(0) == '/')
		{
			// Strip the leading slash away and re-try the path
			// This lets us
			final String newPath = path.substring(1);

			return inner.getResourcesAsStream(newPath);
		}
		else
		{
			return streams;
		}
	}
1227555
private InputStream openFile() throws IOException {
    Path file = Paths.get(filePath);
    if (Files.exists(file)) {
      return Files.newInputStream(file);
    }
    InputStream input = getClass().getResourceAsStream(filePath);
    checkArgument(input != null, "Could not find file: " + filePath);
    return input;
  }
812273
@Override
	public InputStream getResourceAsStream(String resourceName, boolean processingBundle) {

		InputStream is = null;
		try {
			File resource = new File(baseDir, resourceName);
			is = new FileInputStream(resource);
		} catch (FileNotFoundException e) {
			// Nothing to do
		}

		return is;
	}
114197
protected static void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
		BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
		byte[] bytesIn = new byte[BUFFER_SIZE];
		int read = 0;
		while ((read = zipIn.read(bytesIn)) != -1) {
			bos.write(bytesIn, 0, read);
		}
		bos.close();
	}
242625
@Override
    public ZipImporter importFrom(InputStream stream, Filter<ArchivePath> filter) throws ArchiveImportException {
        Validate.notNull(stream, "Stream must be specified");
        Validate.notNull(filter, "Filter must be specified");

        try {
            // Wrap in ZipInputStream if we haven't been given one
            final ZipInputStream zipStream = new ZipInputStream(stream);

            ZipEntry entry;
            while ((entry = zipStream.getNextEntry()) != null) {
                // Get the name
                final String entryName = entry.getName();

                if(!filter.include(ArchivePaths.create(entryName))) {
                    zipStream.closeEntry();
                    continue;
                }

                // Get the archive
                final Archive<?> archive = this.getArchive();

                // Handle directories separately
                if (entry.isDirectory()) {
                    archive.addAsDirectory(entryName);
                    continue;
                }

                final ByteArrayOutputStream output = new ByteArrayOutputStream(8192);
                IOUtil.copy(zipStream, output);
                archive.add(new ByteArrayAsset(output.toByteArray()), entryName);
                zipStream.closeEntry();
            }
        } catch (IOException e) {
            throw new ArchiveImportException("Could not import stream", e);
        }
        return this;
    }
172332
Stream<String> getRessourceLines(Class<?> clazz, String filepath) {
        try (final BufferedReader fileReader = new BufferedReader(
                new InputStreamReader(clazz.getResourceAsStream(filepath),
                StandardCharsets.UTF_8)
        )) {
            // Collect the read lines before converting back to a Java stream
            // so that we can ensure that we close the InputStream and prevent leaks
            return fileReader.lines().collect(Collectors.toList()).stream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
982435
public static InputStream readFileToInputStream(String filePath)
            throws FileNotFoundException {

        InputStream is = null;

        try {

            is = new FileInputStream(filePath);

            logger.info("Completed read file for input stream " + " Path: "
                    + filePath + " at " + PcDateUtils.getNowDateTimeStr());

        } catch (Exception e) {
            logger.error("Error read file." + e);
        }
        return is;

    }
1107389
public static final Properties read(String classpath) throws IOException{
        final URL url = Resources.getResource(classpath);
        final ByteSource byteSource = Resources.asByteSource(url);
        final Properties properties = new Properties();
        InputStream inputStream = null;
        try {
            inputStream = byteSource.openBufferedStream();
            properties.load(inputStream);
        } catch (final IOException ioException) {
            ioException.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (final IOException ioException) {
                    throw ioException;
                }
            }
        }
        return properties;
    }
667194
public static InputStream getResourceInputStreamForZip(ZipFile zipFile,
            String entryName) {
        try {
            return zipFile.getInputStream(zipFile.getEntry(entryName));
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "newZipFile", zipFile, entryName);
        }
    }
1262361
public void loadFile(Resource res, String resourcePath) throws IOException {
	res.createFile(true);
	InputStream is = InfoImpl.class.getResourceAsStream(resourcePath);
	IOUtil.copy(is, res, true);
    }
470668
@Override
	public String getFilePath(String resourcePath) {

		String filePath = null;
		String path = getCompletePath(resourcePath);
		URL url = null;
		try {
			url = ClassLoaderResourceUtils.getResourceURL(path, this);
			String strURL = url.toString();
			if (strURL.startsWith(JawrConstant.FILE_URL_PREFIX)) {
				filePath = new File(url.getFile()).getAbsolutePath();
			} else if (strURL.startsWith(JawrConstant.JAR_URL_PREFIX + JawrConstant.FILE_URL_PREFIX)) {
				String tmp = strURL.substring((JawrConstant.JAR_URL_PREFIX + JawrConstant.FILE_URL_PREFIX).length());
				int idxJarContentSeparator = tmp.indexOf("!");
				if (idxJarContentSeparator != -1) {
					tmp = tmp.substring(0, idxJarContentSeparator);
				}
				filePath = new File(tmp).getAbsolutePath();
			}
		} catch (ResourceNotFoundException e) {
			filePath = null;
		}

		return filePath;
	}
1261670
private ResourceHandler createZipResourceHandler(final URL zipFile) throws IOException {

        final FileSystem fileSystem = newFileSystem(URI.create("jar:" + zipFile), Collections.<String, Object>emptyMap());
        final ResourceManager resMgr = new FileSystemResourceManager(fileSystem);
        return new ResourceHandler(resMgr);
    }
606385
public static File zip(List<String> fileNames, String zipPath) {
    return zip(fileNames, zipPath, null);
  }
1073170
@GET
    @javax.ws.rs.Path("/zip/{path : .*}")
    @Produces("application/zip")
    public Response getDocumentsAsZip(
            @DefaultValue("") @PathParam ("path") final String  pathAsString,
                              @Context            final UriInfo uriInfo) throws IOException {

        final StreamingOutput streamingOutput = new StreamingOutput() {
            @Override
            public void write(OutputStream output) throws IOException, WebApplicationException {
                try {
                    final List<Path> list = documentHelper.list( pathAsString.length() == 0 ? get("/") : get(pathAsString));

                    try (ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(output))) {
                        zipOutputStream.setLevel(9);
                        for (Path path : list) {
                            Path relativized = documentHelper.relativize(path);

                            zipOutputStream.putNextEntry(new ZipEntry(relativized.toString()));

                            Serioulizer.Stream stream = documentHelper.getStream(relativized);
                            if (stream != null) {
                                pipe(stream.getInputStream(), zipOutputStream);
                            }
                            zipOutputStream.closeEntry();
                        }
                    }
                } catch (Exception e) {
                    throw new WebApplicationException(e);
                }
            }
        };

        String filenameWithoutExtension = Joiner.on('-')
                                                .skipNulls()
                                                .join( uriInfo.getBaseUri()
                                                              .getHost(),
                                                       "stnemucod",
                                                       Strings.emptyToNull( pathAsString.replace('/', ' ')
                                                                                        .replace('\\', ' ')
                                                                                        .trim()
                                                                                        .replace(' ', '_')));

        return ok(streamingOutput)
               .type("application/zip")
               .header("Content-Disposition",  "attachment; filename=\"" + filenameWithoutExtension + ".zip\"")
               .build();
    }
1291424
@Override
	public String getFilePath(String resourcePath) {
		String path = resourcePath.replace('/', File.separatorChar);
		return new File(baseDir, path).getAbsolutePath();
	}
1333671
public static InputStream getResourceAsStream(String resourceName) throws URISyntaxException,
            ClassNotFoundException {
        return ResourceUtil.class.getClassLoader().getResourceAsStream(resourceName);
    }