Example #1
0
        public static Stream getInputStreamFromConfigFileEntry(URL mcoURL, string mcoName, string fileName)
        {
            JarFile  mcoJarFile = getConfigJarfile(mcoURL);
            JarEntry entry      = getConfigFileEntry(mcoJarFile, mcoName, fileName);

            try
            {
                if (entry == null)
                {
                    throw new FileNotFoundException();
                }
                return(mcoJarFile.getInputStream(entry));
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            return(null);
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.io.File extract(java.util.jar.JarFile jarFile, java.util.jar.JarEntry jarEntry) throws java.io.IOException
        private File Extract(JarFile jarFile, JarEntry jarEntry)
        {
            File extractedFile = CreateTempFile(jarEntry);

            using (Stream jarInputStream = jarFile.getInputStream(jarEntry))
            {
                Files.copy(jarInputStream, extractedFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            }
            return(extractedFile);
        }