andSmbFileInputStream
からを作成しようとしています。スコープが try-catch ブロックに限定されないように、try-catch ブロックの外側をインスタンス化します。と呼ばれるに対しても同じことを行います。SmbFile
NtlmPasswordAuthentication
SmbFileInputStream
SmbFile
sf
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import jcifs.smb.*;
public static HSSFWorkbook loadWorkbookOrFail(String fileName){
// create a new file input stream with the input file specified by fileName
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("MY_DOMAIN","MY_USERNAME","MY_PASSWORD");
SmbFile sf = null;
SmbFileInputStream fin = null;
try {sf = new SmbFile("smb:\\\\LRIFS2\\Network\\Builders\\Everymoment\\reports\\finished\\Hearthside Ph. 3.xls", auth);
} catch (Exception e){
System.err.println("************************************************* The try block defining sf was caught. sf is null at this time");
throw new IllegalArgumentException("Caught exception in loadWorkbookOrFail(): " + e.getClass().getName());
}
try{SmbFileInputStream fin = new SmbFileInputStream(sf);}
catch(Exception e){
System.err.println("************************************************ SmbFile sf contains " + sf);
// System.err.println("************************************************ SmbFileInputStream fin contains " + fin);
// System.err.println("The command we are trying to run (Drawing a NullPointerException) reads: try{" + fin + " = new SmbFileInputStream(" + sf + ")");
throw new IllegalArgumentException("Exception caught: " + e.getClass().getName());
}
return loadWorkbook(fileName);
}
私が受け取っているエラーメッセージは読み取ります
java.lang.IllegalArgumentException: Exception caught: java.lang.NullPointerException
at com.tem.POIStuff.loadWorkbookOrFail(POIStuff.java:723)
私の現在の理解ではSmbFileInputStream
、最初の try-catch ブロックの外側をインスタンス化することで、その範囲が 2 番目のブロックにまで拡張されます。「実行しようとしているコマンド」で始まるエラー メッセージの出力は次のとおりです。
The command we are trying to run (Drawing a NullPointerException) reads:
try{null = new SmbFileInputStream(smb:\\LRIFS2\Network\Builders\Everymoment\reports\finished\Hearthside Ph. 3.xls)
書式設定または継続性のエラーについては、事前にお詫び申し上げます。スタックオーバーフローのエチケットをまだ学んでいます。