Java Example Program/ Sample Source Code
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class IsFlavorTextType_DataFlavor {
public static void main(String[] args) throws IOException, CloneNotSupportedException, HeadlessException, UnsupportedFlavorException, ClassNotFoundException {
//Creating DataFlavor using constructor
DataFlavor dataFlavor1 = new DataFlavor("text/plain; charset=ASCII", "Plain ASCII text");
DataFlavor dataFlavor2 = new DataFlavor(java.awt.TextField.class, "AWT TextField");
dataFlavor1.clone();
dataFlavor1.equals(dataFlavor2);
dataFlavor1.getDefaultRepresentationClass() ;
dataFlavor1.getReaderForText(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null));
DataFlavor.getTextPlainUnicodeFlavor();
dataFlavor1.isFlavorJavaFileListType();
dataFlavor1.isFlavorRemoteObjectType();
dataFlavor1.isFlavorSerializedObjectType();
dataFlavor1.isFlavorTextType();
dataFlavor1.isMimeTypeEqual(dataFlavor2);
dataFlavor1.isMimeTypeEqual("text/plain");
dataFlavor1.isMimeTypeSerializedObject();
dataFlavor1.isRepresentationClassByteBuffer();
dataFlavor1.isRepresentationClassCharBuffer();
dataFlavor1.isRepresentationClassInputStream();
dataFlavor1.isRepresentationClassReader();
dataFlavor1.isRepresentationClassRemote();
dataFlavor1.isRepresentationClassSerializable();
dataFlavor1.match(dataFlavor2);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
dataFlavor1.writeExternal(oos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
dataFlavor1.readExternal(ois);
DataFlavor.selectBestTextFlavor(new DataFlavor[]{dataFlavor2});
dataFlavor1.setHumanPresentableName("humanPresentableName");
System.out.println("dataFlavor1 equals dataFlavor2: " + dataFlavor1.isMimeTypeEqual(dataFlavor2));
}
} |
|
|