Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

How to get HTML content from system clipboard?

Thread view: 
ZhangJunjing@gmail.com - 20 Apr 2006 12:00 GMT
by doing the following, we can only get the plain text form without
html
tags, how to get HTML content from system clipboard with html tags?

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

Transferable contents = clipboard.getContents(null);
boolean hasTransferableText = (contents != null)
               &&
contents.isDataFlavorSupported(DataFlavor.stringFlavor);

There's no DataFlavor.HTML in DataFlavor class
static DataFlavor imageFlavor
static DataFlavor javaFileListFlavor
static DataFlavor plainTextFlavor
static DataFlavor stringFlavor
static String javaJVMLocalObjectMimeType
static String javaRemoteObjectMimeType
static String javaSerializedObjectMimeType
Philipp Leitner - 20 Apr 2006 12:07 GMT
I am a little puzzled - what do you actually copy into the system
clipboard before?

If you just open a Web Browser and copy text there - well, it /is/ just
plain text then.

If you open the sourcecode view in your browser, and copy it there -
then plaintext is the same as HTML content, isn't it??

/philipp

ZhangJunjing@gmail.com schrieb:
> by doing the following, we can only get the plain text form without
> html
[quoted text clipped - 15 lines]
> static String javaRemoteObjectMimeType
> static String javaSerializedObjectMimeType
Larry Barowski - 20 Apr 2006 14:28 GMT
>I am a little puzzled - what do you actually copy into the system clipboard
>before?
>
> If you just open a Web Browser and copy text there - well, it /is/ just
> plain text then.

It depends on the browser. Generally it will be plain text
and RTF. If you want the formatting, use the RTF. Look
for DataFlavors with MIME type "text/enriched",
"text/richtext", and "text/rtf".
Philipp Leitner - 20 Apr 2006 14:39 GMT
OK, I did not know that. Anyway, I guess it will almost never be HTML
content.

/philipp

Larry Barowski schrieb:
>> I am a little puzzled - what do you actually copy into the system clipboard
>> before?
[quoted text clipped - 6 lines]
> for DataFlavors with MIME type "text/enriched",
> "text/richtext", and "text/rtf".


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.