cfam-matrix Prime Sieves (java code): post processing and reporting threads


import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.util.zip.Deflater.*;
import java.security.*;

// __ rpt post processing and reporting thread
class KThrdPPRptSieve00 extends Thread{
private String aIFlPath;
private int iDPlcs;
private int iHPL;
private String aOFlPath;
private boolean IsOverWrite;
private boolean IsZip;
private boolean IsRmv;

private String aFlSHA256;
private MessageDigest MD = null;
private SUtils24 SUtils;
// __ W
private final String aRngSHA256 = "SHA-256";
private final String aNwLn = System.getProperty("line.separator");
private final int iBfrL = 8192;

// __
KThrdPPRptSieve00(String aThrdNm, String aIFlPath, int iDPlcs, int iHPL, String aOFlPath, boolean IsOverWrite, boolean IsZip, boolean IsRmv) throws FileNotFoundException, NoSuchAlgorithmException{
File IFl = new File(aIFlPath);
if(IFl.exists()){
// __
this.aIFlPath = aIFlPath;
this.iDPlcs = iDPlcs;
this.iHPL = iHPL;
this.aOFlPath = aOFlPath;
this.IsOverWrite = IsOverWrite;
this.IsZip = IsZip;
this.IsRmv = IsRmv;
// __
// aThrdNm = this + aThrdNm;
setName(this + aThrdNm);
MD = MessageDigest.getInstance(aRngSHA256);
SUtils = new SUtils24();
}
else{ throw new FileNotFoundException( aNwLn + "// __ Input file does not exist! | " + IFl.getAbsolutePath() + " | "); }
}

// __
public void run(){
long lTm00 = System.currentTimeMillis();
StringBuffer aB = new StringBuffer();
aB.append(aNwLn).append("// __ thread start time (in ms): |" + lTm00 + "|");
// __
try{
BufferedInputStream BIS = null;
BufferedOutputStream BOS = null;
if(aOFlPath != null){
aOFlPath = aOFlPath.trim();
if(aOFlPath.length() > 0){
File OFl = new File(aOFlPath);
if(OFl.exists()){
if(IsOverWrite){ OFl.delete(); }
else{ throw new IOException( aNwLn + "// __ Output file exists and is not overwritten! : | " + OFl.getAbsolutePath() + " | "); }
}// (OFl.exists())
// __
File IFl = new File(aIFlPath);
BIS = new BufferedInputStream(new FileInputStream(IFl));
BOS = new BufferedOutputStream(new FileOutputStream(OFl));
// __
int iHGap = BIS.read(), lRdCnt = 2;
long lH = iHGap;
BOS.write(SUtils.padString(-1, (new Long(lH)).toString(), iDPlcs).getBytes()); // first is 1 (no left shifting)
iHGap = BIS.read();
while(iHGap != -1){
lH += (iHGap < 0)
else{ throw new IOException( aNwLn + "// __ Undefined output file aOFlPath: | " + aOFlPath + " | "); }
}// (aOFlPath != null)
}catch(FileNotFoundException FNFX){ FNFX.printStackTrace(System.err); }
catch(IOException IOX){ IOX.printStackTrace(System.err); }
}
}


%d bloggers like this: