• Atitit 剪贴板数据类型 DataFlavor 目录 1. HtmlFlavor 1 1.1. allHtmlFlavor 1 1.2. selectionHtmlFlavor 1 1.3. fr


    Atitit 剪贴板数据类型 DataFlavor

    目录

    1. HtmlFlavor 1

    1.1. allHtmlFlavor 1

    1.2. selectionHtmlFlavor 1

    1.3. fragmentHtmlFlavor 2

    2. imageFlavor 2

    2.1. javaFileListFlavor 3

    2.2. plainTextFlavor 3

    2.3. stringFlavor 5

    3. Code 5

     

     

    1. HtmlFlavor
      1. allHtmlFlavor

       representationClass = String

         *     mimeType           = "text/html"

     

      1. selectionHtmlFlavor

     * <pre>

         *     representationClass = String

         *     mimeType           = "text/html"

         * </pre>

         */

        public static DataFlavor selectionHtmlFlavor

      1. fragmentHtmlFlavor

     representationClass = String

         *     mimeType           = "text/html"

         * </pre>

         */

    public static DataFlavor fragmentHtmlFlavor

     

    1. imageFlavor

    * <pre>

         *     representationClass = java.awt.Image

         *     mimeType            = "image/x-java-image"

         * </pre>

         */

        public static final DataFlavor imageFlavor

     

     

     

        public static final String javaSerializedObjectMimeType = "application/x-java-serialized-object";

      1. javaFileListFlavor 

        /**

         * To transfer a list of files to/from Java (and the underlying

         * platform) a <code>DataFlavor</code> of this type/subtype and

         * representation class of <code>java.util.List</code> is used.

         * Each element of the list is required/guaranteed to be of type

         * <code>java.io.File</code>.

         */

        public static final DataFlavor javaFileListFlavor = createConstant("application/x-java-file-list;class=java.util.List", null);

     

      1. plainTextFlavor 

     

      * The <code>DataFlavor</code> representing plain text with Unicode

         * encoding, where:

         * <pre>

         *     representationClass = InputStream

         *     mimeType            = "text/plain; charset=unicode"

         * </pre>

         * This <code>DataFlavor</code> has been <b>deprecated</b> because

         * (1) Its representation is an InputStream, an 8-bit based representation,

         * while Unicode is a 16-bit character set; and (2) The charset "unicode"

         * is not well-defined. "unicode" implies a particular platform's

         * implementation of Unicode, not a cross-platform implementation.

         *

         * @deprecated as of 1.3. Use <code>DataFlavor.getReaderForText(Transferable)</code>

         *             instead of <code>Transferable.getTransferData(DataFlavor.plainTextFlavor)</code>.

         */

        @Deprecated

        public static final DataFlavor plainTextFlavor = createConstant("text/plain; charset=unicode; class=java.io.InputStream", "Plain Text");

     

      1. stringFlavor

        * The <code>DataFlavor</code> representing a Java Unicode String class,

         * where:

         * <pre>

         *     representationClass = java.lang.String

         *     mimeType           = "application/x-java-serialized-object"

         * </pre>

         */

        Pu

     

    1. Code

    /bookmarksHtmlEverythingIndexPrj/src/agenepkg/clip.java

    package agenepkg;

     

    import java.awt.Toolkit;

    import java.awt.datatransfer.Clipboard;

    import java.awt.datatransfer.DataFlavor;

    import java.awt.datatransfer.Transferable;

    import java.awt.datatransfer.UnsupportedFlavorException;

    import java.io.File;

    import java.io.IOException;

    import java.util.List;

     

    @SuppressWarnings("all")

    public class clip {

     

    public static void main(String[] args) throws UnsupportedFlavorException, IOException {

    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

     

    Transferable Transferable1_clipboardContent = clipboard.getContents(null);

    // 获取文本中的Transferable对象

     

    if (Transferable1_clipboardContent == null)

    return;

     

    if (!Transferable1_clipboardContent.isDataFlavorSupported(DataFlavor.javaFileListFlavor))

    return;

     

    List<File> list = (List<File>) (Transferable1_clipboardContent.getTransferData(DataFlavor.javaFileListFlavor));

    for (File file : list) {

    System.out.println(file);

    }

     

    }

     

    }

  • 相关阅读:
    为什么有人说指针是 C 语言的精髓?
    属于编程的黄金时代结束了吗?不,这片领地的大门仍然敞开
    编程和编程语言竟然不是一回事,你知道吗?
    为什么 C 语言是程序员的首选,你知道吗?
    CRoundButton2 -一个花哨的图形按钮
    彩虹按钮
    EnableGroupboxControls -一个非mfc函数,用于启用或禁用groupbox中的所有控件
    CImageButtonWithStyle -按钮使用图像与XP视觉风格
    使用。net SDK编写位图按钮控件
    Joe的自动重复按钮类的。net端口
  • 原文地址:https://www.cnblogs.com/attilax/p/15197243.html
Copyright © 2020-2023  润新知