diff -r 500a16d067e1 -r 8183e063968c java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/PokusnyVypis.java --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/PokusnyVypis.java Wed Dec 15 18:17:15 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -package cz.frantovo.rozsireneAtributy; - -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.file.Path; -import java.nio.file.attribute.UserDefinedFileAttributeView; -import java.util.List; - -/** - * http://freedesktop.org/wiki/CommonExtendedAttributes - * http://download.oracle.com/javase/tutorial/essential/io/fileAttr.html#user - * http://today.java.net/pub/a/today/2008/07/03/jsr-203-new-file-apis.html#so-what-is-a-path-really - * - * $ setfattr -n user.fiki.pozdrav -v 'Dobrý den!' pokus.txt - * - * @author fiki - */ -public class PokusnyVypis { - - /** - * Vypíše rozšířené atributy souboru. - * @param args pole s jedním prvkem – názvem souboru - * @throws IOException - */ - public static void main(String[] args) throws IOException { - File soubor = new File(args[0]); - Path cesta = soubor.toPath(); - UserDefinedFileAttributeView pohled = cesta.getFileAttributeView(UserDefinedFileAttributeView.class); - List jmenaAtributu = pohled.list(); - for (String jmenoAtributu : jmenaAtributu) { - ByteBuffer bajty = ByteBuffer.allocate(pohled.size(jmenoAtributu)); - pohled.read(jmenoAtributu, bajty); - String hodnotaAtributu = dekoduj(bajty); - System.out.println(jmenoAtributu + " = " + hodnotaAtributu); - } - } - - private static String dekoduj(ByteBuffer bajty) { - bajty.flip(); - return Charset.defaultCharset().decode(bajty).toString(); - } -}