Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.FileDescriptor;

import java.lang.reflect.Field;

public class Main {
    public static int getFd(FileDescriptor fileDescriptor) {
        int fdInt = -1;
        try {
            if (fileDescriptor != null) {
                Field descriptor = fileDescriptor.getClass().getDeclaredField("descriptor");
                descriptor.setAccessible(true);
                fdInt = descriptor.getInt(fileDescriptor);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return fdInt;
    }
}