// This method is deprecated. Use soot.util.JasminOutputStream instead. public void writeXXXDeprecated(SootClass cl, String outputDir) { String outputDirWithSep = ""; if (!outputDir.equals("")) outputDirWithSep = outputDir + fileSeparator; try { File tempFile = new File(outputDirWithSep + cl.getName() + ".jasmin"); FileOutputStream streamOut = new FileOutputStream(tempFile); PrintWriter writerOut = new PrintWriter(new EscapedWriter(new OutputStreamWriter(streamOut))); if (cl.containsBafBody()) new soot.baf.JasminClass(cl).print(writerOut); else new soot.jimple.JasminClass(cl).print(writerOut); writerOut.close(); if (Options.v().time()) Timers.v().assembleJasminTimer.start(); // Invoke jasmin { String[] args; if (outputDir.equals("")) { args = new String[1]; args[0] = cl.getName() + ".jasmin"; } else { args = new String[3]; args[0] = "-d"; args[1] = outputDir; args[2] = outputDirWithSep + cl.getName() + ".jasmin"; } jasmin.Main.main(args); } tempFile.delete(); if (Options.v().time()) Timers.v().assembleJasminTimer.end(); } catch (IOException e) { throw new RuntimeException("Could not produce new classfile! (" + e + ")"); } }
public static void main(String args[]) { Timers timer = new Timers(); try { // Get the data set path. String referenceFile = Utils.getOption('r', args); String queryFile = Utils.getOption('q', args); if (referenceFile.length() == 0) throw new IllegalArgumentException( "Required option: File containing" + "the reference dataset."); // Load input dataset. DataSource source = new DataSource(referenceFile); Instances referenceData = source.getDataSet(); Instances queryData = null; if (queryFile.length() != 0) { source = new DataSource(queryFile); queryData = source.getDataSet(); } timer.StartTimer("total_time"); // Get all the parameters. String leafSize = Utils.getOption('l', args); String neighbors = Utils.getOption('k', args); // Validate options. int k = 0; if (neighbors.length() == 0) { throw new IllegalArgumentException( "Required option: Number of " + "furthest neighbors to find."); } else { k = Integer.parseInt(neighbors); if (k < 1 || k > referenceData.numInstances()) throw new IllegalArgumentException("[Fatal] Invalid k"); } int l = 20; if (leafSize.length() != 0) l = Integer.parseInt(leafSize); // Create KDTree. KDTree tree = new KDTree(); tree.setMaxInstInLeaf(l); tree.setInstances(referenceData); // Perform All K-Nearest-Neighbors. if (queryFile.length() != 0) { for (int i = 0; i < queryData.numInstances(); i++) { Instances out = tree.kNearestNeighbours(queryData.instance(i), k); } } else { for (int i = 0; i < referenceData.numInstances(); i++) { Instances out = tree.kNearestNeighbours(referenceData.instance(i), k); } } timer.StopTimer("total_time"); timer.PrintTimer("total_time"); } catch (IOException e) { System.err.println(USAGE); } catch (Exception e) { e.printStackTrace(); } }