Svp aidez moi

  • Auteur de la discussion joujou102
  • Date de début

joujou102

Nouveau membre
Bonjour,
j ai besoin de code source en java pour recuperer les enregistrements d'un fichier texte en ayant position et longueur de ce dernier
 

jojolemariole

Expert
Salut,

RandomAccesFile est ton ami.

public void seek(long pos)
throws IOException


Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.

Parameters:
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
IOException - if pos is less than 0 or if an I/O error occurs.

public int read(byte[] b)
throws IOException


Reads up to b.length bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in the exactly the same way as the InputStream.read(byte[]) method of InputStream.

Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of this file has been reached.
Throws:
IOException - if an I/O error occurs.
 
Vous devez vous inscrire ou vous connecter pour répondre ici.
Derniers messages publiés
Statistiques globales
Discussions
730 134
Messages
6 718 059
Membres
1 586 394
Dernier membre
Manoushk
Partager cette page
Haut