getResourceAsStream() private method

private getResourceAsStream ( global par0 ) : global::java.io.InputStream
par0 global
return global::java.io.InputStream
Ejemplo n.º 1
0
    public static File extractResource(Class cls, string name, File directory, string prefix, string suffix)
    {
      InputStream resourceAsStream = cls.getResourceAsStream(name);
      if (resourceAsStream == null)
        return (File) null;
      File file = (File) null;
      int num1 = 0;
      IOException ioException1;
      try
      {
        if (prefix == null && suffix == null)
        {
          File.__\u003Cclinit\u003E();
          file = new File(directory, new File(name).getName());
          num1 = file.exists() ? 1 : 0;
        }
        else
          file = File.createTempFile(prefix, suffix, directory);
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] numArray = new byte[resourceAsStream.available()];
        int num2;
        while ((num2 = resourceAsStream.read(numArray)) > 0)
          fileOutputStream.write(numArray, 0, num2);
        resourceAsStream.close();
        fileOutputStream.close();
        goto label_14;
      }
      catch (IOException ex)
      {
        int num2 = 1;
        ioException1 = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num2);
      }
      IOException ioException2 = ioException1;
      if (file != null && num1 == 0)
        file.delete();
      throw Throwable.__\u003Cunmap\u003E((Exception) ioException2);
label_14:
      return file;
    }