RandomAccessFile class getFD () método : Aquí, vamos a aprender sobre el método getFD () de RandomAccessFile Class con su sintaxis y su ejemplo.
RandomAccessFile Class getFD () método
- método
- getFD () está disponible en java.io Class.
- getFD () método se utiliza para recuperar el descriptor de archivo vinculado con esta corriente RandomAccessFile.
- getFD () método es un método no class, es accesible sólo con el objeto package y si tratamos de acceder al método con el nombre static entonces obtendrá un error.
- getFD () método puede class una excepción en el momento de devolver el canal de archivo.
IOException
: Esta excepción puede class mientras que realiza la operación de entrada / salida.
Sintaxis:
public final FileChannel getChannel();
Parámetro (s):
No acepta cualquier parámetro.
throw valor:
El tipo Return de este método es
FileDescriptor
, devuelve objeto FileDescriptor conectado con esta corriente.
Ejemplo:
// Java program to demonstrate the example
// of final FileChannel getChannel() method of
// RandomAccessFile
import java.io.*;
public class RAFGetChannel {
public static void main(String[] args) throws Exception {
// Instantiate a random access file
// object with file name and permissions
RandomAccessFile ra_f = new RandomAccessFile("e:/includehelp.txt", "rw");
// By using writeUTF() method is to
// write data in the file
ra_f.writeUTF("Welcome, in Java World!!!");
// Initially set the file pointer
// is at 0 for reading the file
ra_f.seek(0);
// To read file content by using
// readUTF()
System.out.println("ra_f .readUTF(): " + ra_f.readUTF());
// By using getChannel() method is to
// return the channel linked with this
// object
System.out.println("ra_f.getChannel(): " + ra_f.getChannel());
// By using close() method isto
// close this stream ran_f
ra_f.close();
}
}
salida
E:Programs>java RAFGetChannel
ra_f .readUTF(): Welcome, in Java World!!!
ra_f.getChannel(): [email protected]
_105_ _106_ _107_