All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.tundeadetunji.Machine Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
package io.github.tundeadetunji;

import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

public final class Machine {
    public static Object getTextFromClipboard() throws IOException, UnsupportedFlavorException {
        return Toolkit.getDefaultToolkit()
                .getSystemClipboard().getData(DataFlavor.stringFlavor);
    }

    public static void sendTextToClipboard(String text) {
        Toolkit.getDefaultToolkit()
                .getSystemClipboard()
                .setContents(
                        new StringSelection(text),
                        null
                );
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy