|
|
package com.moyosoft.jocapplet;
import java.io.*;
import javax.swing.*;
import com.moyosoft.connector.ms.outlook.*;
import com.moyosoft.connector.ms.outlook.demo.gui.*;
public class JocDemoApplet extends java.applet.Applet
{
public JocDemoApplet()
{
super();
}
public void init()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{
}
try
{
initLibrary();
// Open the contacts explorer window
ContactExplorer.open();
}
catch (IOException e)
{
// Unable to copy/load the library
e.printStackTrace();
}
}
private void initLibrary() throws IOException
{
File tempDll = File.createTempFile("joc-temp-", ".dll");
tempDll.deleteOnExit();
InputStream dllStream = JocDemoApplet.class.getClassLoader().getResourceAsStream("joutlookconnector.dll");
FileOutputStream fileStream = new FileOutputStream(tempDll);
copy(dllStream, fileStream);
dllStream.close();
fileStream.close();
// Set the path to the DLL library
Outlook.setLibraryPath(tempDll.getAbsolutePath());
}
private void copy(InputStream in, OutputStream out) throws IOException
{
int read = 0;
byte[] buf = new byte[1024];
while(in.available() > 0)
{
read = in.read(buf);
if(read <= 0)
{
break;
}
out.write(buf, 0, read);
}
}
}
|