Вот такой
выплёвывает такую ошибку:
Java:
import java.io.*;
import java.net.*;
class FileDownloader {
public static boolean start(String sURL, String sFilePath) {
InputStream is = null;
try {
URL u = new URL(sURL);
is = u.openStream();
BufferedInputStream bis = new BufferedInputStream(is);
int bufSize = 1024;
byte[] buffer = new byte[bufSize];
FileOutputStream fos = new FileOutputStream(sFilePath);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int bytes;
while((bytes = bis.read(buffer)) != -1)
bos.write(buffer, 0, bytes);
fos.flush();
fos.close();
return true;
}
catch (MalformedURLException mue) {
System.err.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
return false;
}
catch (IOException ioe) {
System.err.println("Oops - an IOException happened.");
ioe.printStackTrace();
return false;
}
finally {
try {
is.close();
}
catch (IOException ioe) {}
}
}
}
Visual Basic:
Function DownloadFile(sURL As String, sFilePath As String) As Boolean
On Error GoTo ErrH
Dim jClassFD As JavaClass
Dim jMethod As JavaMethod
Set jClassFD = GetJavaClass("FileDownloader")
If jClassFD Is Nothing Then Exit Function
Set jMethod = jClassFD.GetMethod("start", "(Ljava/lang/String;Ljava/lang/String;)Z")
DownloadFile = jMethod.Invoke(, sURL, sFilePath)
Exit Function
ErrH:
Call WriteJavaError(Error$)
Exit Function
End Function
%REM
Library LS2J
Created Jun 10, 2010 by я
Description: основной функционал для работы с бриджами LS2J
%END REM
Option Public
UseLSX "*javacon"
Public jSession As JavaSession
Sub Initialize()
Set jSession = New JavaSession()
End Sub
%REM
Function GetJavaClass
Description: возвращает объект класса
%END REM
Function GetJavaClass(sClassName As String) As JavaClass
On Error GoTo ErrH
Set GetJavaClass = jSession.GetClass(sClassName)
If Not GetJavaClass Is Nothing Then Exit Function
ErrH:
Call WriteJavaError(Error$)
Exit Function
End Function
%REM
Sub WriteJavaError
Description: пока только вывод сообщения об ошибке
%END REM
Sub WriteJavaError(sError As String)
Dim jError As JavaError
Set jError = jSession.getLastJavaError()
Messagebox sError + Chr(13) + jError.StackTrace, 48, "Lotus Notes..."
End Sub
Почитал, это что-то типа Object variable not set, но как его понять, в какой строке, какой объект?LS2J Error: Threw java.lang.NullPointerException
at FileDownloader.start(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at lotus.domino.JavaConnectInvoker.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at lotus.domino.JavaConnectLoader.invoke(Unknown Source)