本文介绍了在Mac OSX中复制文件所需的DataFlavor是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在研究可以将文件复制到系统剪贴板的Java代码。
I'm currently working on Java code that can copy files into the system clipboard.
对于Windows和Linux,我已经开始工作了。对于OSX,我尝试了几种口味,但Finder中的粘贴操作从未激活。
For Windows and Linux I already got it working. For OSX I tried several flavors but the "Paste" action in Finder never cames active.
任何想法Finder需要哪些DataFlavor设置?
Any idea which DataFlavor settings are required for Finder?
使用的口味:
DataFlavor.javaFileListFlavor
URILIST_FLAVOR = new DataFlavor( "text/uri-list" );
XFILELIST_FLAVOR = new DataFlavor( "application/x-java-file-list" );
GNOMEFILELIST_FLAVOR = new DataFlavor( "x-special/gnome-copied-files" );
返回风味数据的方法:
public Object getTransferData( DataFlavor flavor ) throws UnsupportedFlavorException, IOException {
if( FILELIST_FLAVOR.equals( flavor ) ) {
if( List.class == flavor.getRepresentationClass() ) {
return Arrays.asList( files );
} else if( InputStream.class == flavor.getRepresentationClass() ) {
return getStreamData( files, null );
}
} else if( DataFlavor.javaFileListFlavor.equals( flavor ) ) {
if( List.class == flavor.getRepresentationClass() ) {
return locallist;
} else if( InputStream.class == flavor.getRepresentationClass() ) {
return getStreamData( files, null );
}
} else if( URILIST_FLAVOR.equals( flavor ) ) {
if( List.class == flavor.getRepresentationClass() ) {
return Arrays.asList( files );
} else if( InputStream.class == flavor.getRepresentationClass() ) {
return getStreamData( files, null );
}
} else if( GNOMEFILELIST_FLAVOR.equals( flavor ) ) {
if( List.class == flavor.getRepresentationClass() ) {
return Arrays.asList( files );
} else if( InputStream.class == flavor.getRepresentationClass() ) {
// FIXME support cut and copy
return getStreamData( files, "copy" );
}
} else if( XFILELIST_FLAVOR.equals( flavor ) ) {
if( List.class == flavor.getRepresentationClass() ) {
return locallist;
} else if( InputStream.class == flavor.getRepresentationClass() ) {
return getStreamData( files, null );
}
}
throw new UnsupportedFlavorException( flavor );
}
谢谢,$ b $bAndré
Thanks,André
推荐答案
也许你应该尝试。
摘自API文档:
DataFlavor#javaFileListFlavor ()
这篇关于在Mac OSX中复制文件所需的DataFlavor是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!