Example usage for java.io FileInputStream getClass

List of usage examples for java.io FileInputStream getClass

Introduction

In this page you can find the example usage for java.io FileInputStream getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.acmsl.commons.utils.io.FileUtils.java

/**
 * Retrieves the {@link File} associated to given {@link FileInputStream}, if possible.
 * @param inputStream the input stream./*from   ww w  .  j av  a 2s .c  om*/
 * @return the file.
 */
@Nullable
public File retrieveFile(@NotNull final FileInputStream inputStream) {
    @Nullable
    final File result;

    @Nullable
    String t_strPath = null;

    try {
        @Nullable
        final Field field = inputStream.getClass().getDeclaredField("path");
        field.setAccessible(true);
        t_strPath = (String) field.get(inputStream);
    } catch (@NotNull final Throwable noField) {
        System.err.println(noField.getMessage());
    }

    if (t_strPath == null) {
        result = null;
    } else {
        result = new File(t_strPath);
    }

    return result;
}