java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/PokusnýVýpis.java
changeset 6 734f104f2869
parent 5 8171c6c30613
child 7 48d5fdb68798
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/PokusnýVýpis.java	Wed Dec 15 19:18:08 2010 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,44 +0,0 @@
     1.4 -package cz.frantovo.rozsireneAtributy;
     1.5 -
     1.6 -import java.io.File;
     1.7 -import java.io.IOException;
     1.8 -import java.nio.ByteBuffer;
     1.9 -import java.nio.charset.Charset;
    1.10 -import java.nio.file.Path;
    1.11 -import java.nio.file.attribute.UserDefinedFileAttributeView;
    1.12 -import java.util.List;
    1.13 -
    1.14 -/**
    1.15 - * http://freedesktop.org/wiki/CommonExtendedAttributes
    1.16 - * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user
    1.17 - * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really
    1.18 - *
    1.19 - * $ setfattr -n user.fiki.pozdrav -v 'Dobrý den!' pokus.txt
    1.20 - *
    1.21 - * @author fiki
    1.22 - */
    1.23 -public class PokusnýVýpis {
    1.24 -
    1.25 -	/**
    1.26 -	 * Vypíše rozšířené atributy souboru.
    1.27 -	 * @param args pole s jedním prvkem – názvem souboru
    1.28 -	 * @throws IOException
    1.29 -	 */
    1.30 -	public static void main(String[] args) throws IOException {
    1.31 -		File soubor = new File(args[0]);
    1.32 -		Path cesta = soubor.toPath();
    1.33 -		UserDefinedFileAttributeView pohled = cesta.getFileAttributeView(UserDefinedFileAttributeView.class);
    1.34 -		List<String> jménaAtributů = pohled.list();
    1.35 -		for (String jménoAtributu : jménaAtributů) {
    1.36 -			ByteBuffer bajty = ByteBuffer.allocate(pohled.size(jménoAtributu));
    1.37 -			pohled.read(jménoAtributu, bajty);
    1.38 -			String hodnotaAtributu = dekóduj(bajty);
    1.39 -			System.out.println(jménoAtributu + " = " + hodnotaAtributu);
    1.40 -		}
    1.41 -	}
    1.42 -
    1.43 -	private static String dekóduj(ByteBuffer bajty) {
    1.44 -		bajty.flip();
    1.45 -		return Charset.defaultCharset().decode(bajty).toString();
    1.46 -	}
    1.47 -}