Hi,
wahrscheinlich mal wieder ein Anfängerfehler. Ich sehe einfach nicht, warum hier eine "java.lang.NullPointerException" kommt.
[JAVA=3]import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class ReadPDF{
private static boolean testsw;
private static String userPath=System.getProperty("user.home")+System.getProperty("file.separator");
private static long inLength;
private static ByteBuffer[] inBuffer;
public static long read(File in) throws IOException {
testsw=Parameters.retrieveBoolean("ReadPDF.testsw");
FileChannel eingabe=new FileInputStream(in).getChannel();
inLength=0;
if (testsw) ErrorWindow.errorMsg("v0.1 ReadPDF:21 size="+eingabe.size());
try {
inLength=eingabe.read(inBuffer);
} catch (IOException e) {ErrorWindow.errorMsg("v0.1 ReadPDF:24 "+e.toString());
throw e;
} finally {
if (eingabe != null) eingabe.close();
else {
ErrorWindow.errorMsg("v0.1 ReadPDF:29 couldn't open "+in.getAbsolutePath());
ErrorWindow.systemExit(-1);
}
}
return inLength;
}
}
[/code]
wahrscheinlich mal wieder ein Anfängerfehler. Ich sehe einfach nicht, warum hier eine "java.lang.NullPointerException" kommt.
[JAVA=3]import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class ReadPDF{
private static boolean testsw;
private static String userPath=System.getProperty("user.home")+System.getProperty("file.separator");
private static long inLength;
private static ByteBuffer[] inBuffer;
public static long read(File in) throws IOException {
testsw=Parameters.retrieveBoolean("ReadPDF.testsw");
FileChannel eingabe=new FileInputStream(in).getChannel();
inLength=0;
if (testsw) ErrorWindow.errorMsg("v0.1 ReadPDF:21 size="+eingabe.size());
try {
inLength=eingabe.read(inBuffer);
} catch (IOException e) {ErrorWindow.errorMsg("v0.1 ReadPDF:24 "+e.toString());
throw e;
} finally {
if (eingabe != null) eingabe.close();
else {
ErrorWindow.errorMsg("v0.1 ReadPDF:29 couldn't open "+in.getAbsolutePath());
ErrorWindow.systemExit(-1);
}
}
return inLength;
}
}
[/code]
Code:
v0.1 ReadPDF:21 size=258968, Thread=main
Exception in thread "main" java.lang.NullPointerException
at java.nio.channels.FileChannel.read(Unknown Source)
at de.virginiacity.software.ReadPDF.read(ReadPDF.java:23)
at de.virginiacity.software.NKAbrech.main(NKAbrech.java:61)
Zuletzt bearbeitet: