Disqus for hsalearn

Java Operator System Utility.

Get name of operator system.
    public static String getOsName() {
        System.getProperty("os.name");
    }

Check operator system is Windows?
    public static boolean isWindows() {
        return getOsName().startsWith("Windows");
    }

Get text from clipboard.
    public static String getTextFromClipBoard() {
        String text = "";
        try {
            text = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
            return text;
        } catch (UnsupportedFlavorException | IOException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        }
        return text;
    }

Set text to clipboard.
    public static void setTextToClipBoard(String value) {
        StringSelection text = new StringSelection(value);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(text, text);
    }






    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

 
Copyright © 2013. HSA Learn - All Rights Reserved
Template Created by ThemeXpose | Published By Gooyaabi Templates