本文整理汇总了Java中java.awt.datatransfer.SystemFlavorMap.encodeDataFlavor方法的典型用法代码示例。如果您正苦于以下问题:Java SystemFlavorMap.encodeDataFlavor方法的具体用法?Java SystemFlavorMap.encodeDataFlavor怎么用?Java SystemFlavorMap.encodeDataFlavor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.SystemFlavorMap
的用法示例。
在下文中一共展示了SystemFlavorMap.encodeDataFlavor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializedObject
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
private Object getSerializedObject(DataFlavor f)
throws IOException, UnsupportedFlavorException {
String nativeFormat = SystemFlavorMap.encodeDataFlavor(f);
if ((nativeFormat == null) ||
!data.isNativeFormatAvailable(nativeFormat)) {
throw new UnsupportedFlavorException(f);
}
byte bytes[] = data.getSerializedObject(f.getRepresentationClass());
if (bytes == null) {
// awt.4F=Data is not available
throw new IOException(Messages.getString("awt.4F")); //$NON-NLS-1$
}
ByteArrayInputStream str = new ByteArrayInputStream(bytes);
try {
return new ObjectInputStream(str).readObject();
} catch (ClassNotFoundException ex) {
throw new IOException(ex.getMessage());
}
}
示例2: getSerializedObject
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
private Object getSerializedObject(DataFlavor f)
throws IOException, UnsupportedFlavorException {
String nativeFormat = SystemFlavorMap.encodeDataFlavor(f);
if ((nativeFormat == null) ||
!data.isNativeFormatAtailable(nativeFormat)) {
throw new UnsupportedFlavorException(f);
}
byte bytes[] = data.getSerializedObject(f.getRepresentationClass());
if (bytes == null) {
// awt.4F=Data is not available
throw new IOException(Messages.getString("awt.4F")); //$NON-NLS-1$
}
ByteArrayInputStream str = new ByteArrayInputStream(bytes);
try {
return new ObjectInputStream(str).readObject();
} catch (ClassNotFoundException ex) {
throw new IOException(ex.getMessage());
}
}
示例3: getSerializedObject
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public byte[] getSerializedObject(Class<?> clazz) {
String nativeFormat = SystemFlavorMap.encodeDataFlavor(
new DataFlavor(clazz, null));
return getDataObjectSerialized(pointer, nativeFormat);
}