Java 8 FileDescriptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 FileDescriptor class.

This code example shows how to use the following methods:
     * Constructor 
     */ 
    public ServerSocketChannelImpl(SelectorProvider sp) throws IOException {
        super(sp);
        status = SERVER_STATUS_OPEN;
        fd = new FileDescriptor();
        Platform.getNetworkSystem().createStreamSocket(fd,
                NetUtil.preferIPv4Stack()); 
        impl = new PlainServerSocketImpl(fd);
        socket = new ServerSocketAdapter(impl, this);
    } 
     
    // for native call 
    @SuppressWarnings("unused") 
    private ServerSocketChannelImpl() throws IOException { 
        super(SelectorProvider.provider());
        status = SERVER_STATUS_OPEN;
        fd = new FileDescriptor();
        impl = new PlainServerSocketImpl(fd);
        socket = new ServerSocketAdapter(impl, this);
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt$
        command.append(" /system/bin/app_process /system/bin --application");
        if (niceName != null) {
            command.append(" '--nice-name=").append(niceName).append("'");
        } 
        command.append(" com.android.internal.os.WrapperInit ");
        command.append(pipeFd != null ? pipeFd.getInt$() : 0);
        command.append(' ');
        command.append(targetSdkVersion);
        Zygote.appendQuotedShellArgs(command, args);
        Zygote.execShell(command.toString());
    } 
 
    /** 
     * Executes a standalone application with a wrapper command. 
     * This method never returns. 
     * 
     * @param invokeWith The wrapper command. 
     * @param classPath The class path. 
     * @param className The class name to invoke. 
     * @param args Arguments for the main() method of the specified class. 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    @Override public SourceChannel source() {
        return source;
    } 
 
    /** 
     * FileChannelImpl doesn't close its fd itself; it calls close on the object it's given. 
     */ 
    private static class FdCloser implements Closeable {
        private final FileDescriptor fd;
        private FdCloser(FileDescriptor fd) {
            this.fd = fd;
        } 
        public void close() throws IOException { 
            IoUtils.close(fd);
        } 
    } 
 
    private class PipeSourceChannel extends Pipe.SourceChannel implements FileDescriptorHandler {
        private final FileDescriptor fd;
        private final FileChannelImpl channel;

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
    /** 
     * Returns a new FileDescriptor whose internal integer is set to 'fd'. 
     */ 
    public static FileDescriptor newFileDescriptor(int fd) {
        FileDescriptor result = new FileDescriptor();
        setFd(result, fd);
        return result;
    } 
 
    /** 
     * Creates a pipe by calling pipe(2), returning the two file descriptors in 
     * elements 0 and 1 of the array 'fds'. fds[0] is the read end of the pipe. 
     * fds[1] is the write end of the pipe. Throws an appropriate IOException on failure. 
     */ 
    public static native void pipe(int[] fds) throws IOException;
 
    /** 
     * Sets the int file descriptor within the given FileDescriptor 'fd' to 'newValue'. 
     */ 
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt$
    private void unTagSocketFd(FileDescriptor fd) {
        final SocketTags options = threadSocketTags.get();
        if (options.statsTag == -1 && options.statsUid == -1) return;
 
        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
            final int errno = native_untagSocketFd(fd);
            if (errno < 0) {
                Log.w(TAG, "untagSocket(" + fd.getInt$() + ") failed with errno " + errno);
            } 
        } 
    } 
 
    public static class SocketTags { 
        public int statsTag = -1;
        public int statsUid = -1;
    } 
 
    public static void setKernelCounterSet(int uid, int counterSet) {
        if (SystemProperties.getBoolean(PROP_QTAGUID_ENABLED, false)) {
            final int errno = native_setCounterSet(counterSet, uid);
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getInt$
        command.append(" /system/bin/app_process /system/bin --application");
        if (niceName != null) {
            command.append(" '--nice-name=").append(niceName).append("'");
        } 
        command.append(" com.android.internal.os.WrapperInit ");
        command.append(pipeFd != null ? pipeFd.getInt$() : 0);
        command.append(' ');
        command.append(targetSdkVersion);
        Zygote.appendQuotedShellArgs(command, args);
        Zygote.execShell(command.toString());
    } 
 
    /** 
     * Executes a standalone application with a wrapper command. 
     * This method never returns. 
     * 
     * @param invokeWith The wrapper command. 
     * @param classPath The class path. 
     * @param className The class name to invoke. 
     * @param args Arguments for the main() method of the specified class. 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: sync, valid
     * <code>RandomAccessFile</code>. 
     */ 
    public void flush() throws IOException {
	// Fix: 4636212.  When this FIleDescriptor is not valid, do nothing. 
	FileDescriptor fd = file.getFD();
        if(fd.valid()) 
	    fd.sync();
    } 
 
    public void close() throws IOException {
        file.close();
    } 
 
    public long getFilePointer() throws IOException {
        return file.getFilePointer();
    } 
 
    public void seek(long pos) throws IOException {
        file.seek(pos);
    } 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
import java.nio.channels.ServerSocketChannel; 
import java.nio.channels.SocketChannel; 
import java.nio.channels.spi.SelectorProvider; 
import org.apache.harmony.luni.net.PlainServerSocketImpl; 
import org.apache.harmony.luni.platform.FileDescriptorHandler; 
import org.apache.harmony.luni.platform.Platform; 
 
/** 
 * The default ServerSocketChannel. 
 */ 
public final class ServerSocketChannelImpl 
        extends ServerSocketChannel implements FileDescriptorHandler {
 
    private final FileDescriptor fd = new FileDescriptor();
    private final SocketImpl impl = new PlainServerSocketImpl(fd);
    private final ServerSocketAdapter socket = new ServerSocketAdapter(impl, this);
 
    private boolean isBound = false;
 
    private static class AcceptLock {} 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    public int describeContents() { 
        return 0; 
    } 
 
    public void writeToParcel(Parcel out, int flags) {
        FileDescriptor fileDescriptor = new FileDescriptor();
        nativeSetFD(fileDescriptor, mFd);
        out.writeFileDescriptor(fileDescriptor);
    } 
 
    public static final Parcelable.Creator<NativeFDParcelable> CREATOR
        = new Parcelable.Creator<NativeFDParcelable>() { 
            public NativeFDParcelable createFromParcel(Parcel in) { 
                return new NativeFDParcelable(in); 
            } 
 
            public NativeFDParcelable[] newArray(int size) { 
                return new NativeFDParcelable[size]; 
            } 
        }; 
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
     */ 
    public RawSocket(String interfaceName, short protocolType)
        throws SocketException {
        mInterfaceName = interfaceName;
        mProtocolType = protocolType;
        fd = new FileDescriptor();
        create(fd, mProtocolType, mInterfaceName);
        guard.open("close");
    } 
 
    /** 
     * Reads a raw packet into the specified buffer, with the 
     * specified timeout.  If the destPort is -1, then the IP 
     * destination port is not verified, otherwise only packets 
     * destined for the specified UDP port are returned.  Returns the 
     * length actually read.  No indication of overflow is signaled. 
     * The packet data will start at the IP header (EthernetII 
     * dest/source/type headers are removed). 
     */ 
    public int read(byte[] packet, int offset, int byteCount, int destPort,
Full Snippet Info
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 FileDescriptor Questions & Answers:

See Code Examples for Java 8 FileDescriptor Methods: