answersLogoWhite

0

// Concise version

public static final void placeStringOnClipboard(final String str) {

Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(str), null);

}

// Same thing, spread out

public static final void placeStringOnClipboard(final String str) {

// Get the system toolkit

final Toolkit toolkit = Toolkit.getDefaultToolkit();

// Use the toolkit to get the system clipboard

final Clipboard clipboard = toolkit.getSystemClipboard();

// Set the contents of the clipboard to our string

clipboard.setContents(new StringSelection(str), null);

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Concat a string without using any inbuilt function in java?

Use "+". Example: String string = "does this answer " + "your question?";


Write a program in java to display a string message using Servlets?

i dont no string for servlate


How can find the length of a string in java without using fun?

Use length() method. Example: "java".length();


Sample of heap sort in java using string?

because of the gravity of the earth


What are some ways in order to perform String comparison in Java?

String comparison in Java features four ways. These ways are String comparison using equals method, equalsIgnoreCase method, CompareTo method, and CompareToIgnoreCase method.


How do you convert string to int in Java?

One can convert a string variable to an int variable in Java using the parse integer command. The syntax is int foo = Integer.parseInt("1234"). This line will convert the string in the parenthesis into an integer.


What are some example for string formatting in Java?

There are lots of examples of string formatting in Java. It can be difficult at times. Some of these examples are, but are not limited to; align, string, format, and JAVA.


Can InetAddress be used with inet6 in java?

Yes. Using the method InetAddress.getByName( String name) for instance.


Where could one get advice on converting int to string using java?

There are a number of technology sites that offer good advice on converting int to string using Java. One can find helpful advice on sites such as Stack Overflow, eHow and the Oracle website.


Is String in java a class or object?

String is a pre-defined class in Java. For example: String s = new String("This is a string"); the variable s is now a String object since it was declared and initialized in the String class.


How do you create a bean in Java?

In eclipse java beans can be created by using getters and setters. Example: public class Login { public String lmail; public String getLmail() { return lmail; } public void setLmail(String lmail) { this.lmail = lmail; }


What does it mean to have a string split in java?

To have a string split in Java means that a string array, containing substrings (can be delimited by elements of a specified string or Unicode character array), is returned.