Java Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Java Examples

Quick Start
Unicode
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
SFTP
Signatures
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
Upload
XML
XMP
Zip

More Examples...
Email Object
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

Convert HTML String to MHT String

Java source code example to convert an in-memory HTML string to an in-memory MHT (MIME) string.

Download Java Programming Examples

// Chilkat Java Example Program:
// Save an in-memory HTML string to a .mht web archive.
	
import com.chilkatsoft.CkMht;
import com.chilkatsoft.CkString;

public class HtmlToMht {
	
  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) 
  {
    // Create a MHT object...
    CkMht mht = new CkMht();
    mht.UnlockComponent("anything for 30-day trial");
    
    String html = "<html><body><img src=\"http://www.chilkatsoft.com/images/dude.gif\"><br>Chilkat Software Inc</body></html>";
    CkString strMht = new CkString();
    boolean success = mht.HtmlToMHT(html,strMht);
    if (!success)
    {
    	mht.SaveLastError("lastError.txt");	
    }
    else
    {
    	// Save the string to a file...
    	strMht.saveToFile("output/dude.mht","windows-1252");
    	
    	// To access the MHT string, do this:
    	String mhtString = strMht.getString();
    }
    
  }
}






 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.