io.github.tundeadetunji.Machine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code Show documentation
Show all versions of code Show documentation
A programmer's toolkit - contains handy functions for daily use.
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