Java7: Lire un fichier avec readAllBytes

Author:

 int,string,char,static, url, socket, url, socket, java
Download

/**
 * @(#)ExempleReadAllBytes.java
 *
 *
 * @author 
 * @version 1.00 2012/12/11
 */
 
import java.nio.file.*;
import java.nio.*;
 
public class ExempleReadAllBytes {
 
    public static void main(String[] args) throws Exception
    	 {
			Path path = Paths.get("c:/test.txt");
			// Lire les octets du fichier
			byte[] contenu = Files.readAllBytes(path);
			// Parcourir les octets et afficher les caractères correspondants
			for (byte b : contenu) 
				   {
				System.out.print((char)b);
				   }
    	 }
}

Cet article Java7: Lire un fichier avec readAllBytes est apparu en premier sur .