Example usage for java.io IOException printStackTrace

List of usage examples for java.io IOException printStackTrace

Introduction

In this page you can find the example usage for java.io IOException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:net.liuxuan.Tools.signup.SignupV2ex.java

public static void main(String[] args) {
    try {/*from   w w w  .ja va  2 s  .  com*/
        SignupV2ex sign = new SignupV2ex();
        sign.getLoginForm();
        sign.doLoginAction();
        System.out.println("------------check---------------");
        sign.check();
    } catch (IOException ex) {
        ex.printStackTrace();
        //            Logger.getLogger(SignupV2ex.class.getName()).log(Level.SEVERE, null, ex);
    } catch (URISyntaxException ex) {
        ex.printStackTrace();
        ;
        //            Logger.getLogger(SignupV2ex.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:MiniCluster.java

/**
 * Runs the {@link MiniAccumuloCluster} given a -p argument with a property file. Establishes a shutdown port for asynchronous operation.
 * //  w  ww .j  a  v a  2  s .  c om
 * @param args
 *          An optional -p argument can be specified with the path to a valid properties file.
 */
public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    opts.parseArgs(MiniCluster.class.getName(), args);

    if (opts.printProps) {
        printProperties();
        System.exit(0);
    }

    int shutdownPort = 4445;

    final File miniDir;

    if (opts.prop.containsKey(DIRECTORY_PROP))
        miniDir = new File(opts.prop.getProperty(DIRECTORY_PROP));
    else
        miniDir = Files.createTempDir();

    String rootPass = opts.prop.containsKey(ROOT_PASSWORD_PROP) ? opts.prop.getProperty(ROOT_PASSWORD_PROP)
            : "secret";
    String instanceName = opts.prop.containsKey(INSTANCE_NAME_PROP) ? opts.prop.getProperty(INSTANCE_NAME_PROP)
            : "accumulo";
    MiniAccumuloConfig config = new MiniAccumuloConfig(miniDir, instanceName, rootPass);

    if (opts.prop.containsKey(NUM_T_SERVERS_PROP))
        config.setNumTservers(Integer.parseInt(opts.prop.getProperty(NUM_T_SERVERS_PROP)));
    if (opts.prop.containsKey(ZOO_KEEPER_PORT_PROP))
        config.setZooKeeperPort(Integer.parseInt(opts.prop.getProperty(ZOO_KEEPER_PORT_PROP)));
    //    if (opts.prop.containsKey(JDWP_ENABLED_PROP))
    //      config.setJDWPEnabled(Boolean.parseBoolean(opts.prop.getProperty(JDWP_ENABLED_PROP)));
    //    if (opts.prop.containsKey(ZOO_KEEPER_MEMORY_PROP))
    //      setMemoryOnConfig(config, opts.prop.getProperty(ZOO_KEEPER_MEMORY_PROP), ServerType.ZOOKEEPER);
    //    if (opts.prop.containsKey(TSERVER_MEMORY_PROP))
    //      setMemoryOnConfig(config, opts.prop.getProperty(TSERVER_MEMORY_PROP), ServerType.TABLET_SERVER);
    //    if (opts.prop.containsKey(MASTER_MEMORY_PROP))
    //      setMemoryOnConfig(config, opts.prop.getProperty(MASTER_MEMORY_PROP), ServerType.MASTER);
    //    if (opts.prop.containsKey(DEFAULT_MEMORY_PROP))
    //      setMemoryOnConfig(config, opts.prop.getProperty(DEFAULT_MEMORY_PROP));
    //    if (opts.prop.containsKey(SHUTDOWN_PORT_PROP))
    //      shutdownPort = Integer.parseInt(opts.prop.getProperty(SHUTDOWN_PORT_PROP));

    Map<String, String> siteConfig = new HashMap<String, String>();
    for (Map.Entry<Object, Object> entry : opts.prop.entrySet()) {
        String key = (String) entry.getKey();
        if (key.startsWith("site."))
            siteConfig.put(key.replaceFirst("site.", ""), (String) entry.getValue());
    }

    config.setSiteConfig(siteConfig);

    final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(config);

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                accumulo.stop();
                FileUtils.deleteDirectory(miniDir);
                System.out.println("\nShut down gracefully on " + new Date());
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });

    accumulo.start();

    printInfo(accumulo, shutdownPort);

    // start a socket on the shutdown port and block- anything connected to this port will activate the shutdown
    ServerSocket shutdownServer = new ServerSocket(shutdownPort);
    shutdownServer.accept();

    System.exit(0);
}

From source file:HelloSmartsheet.java

public static void main(String[] args) {
    HttpURLConnection connection = null;
    StringBuilder response = new StringBuilder();

    //We are using Jackson JSON parser to deserialize the JSON. See http://wiki.fasterxml.com/JacksonHome
    //Feel free to use which ever library you prefer.
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    try {/*from w w w .  ja v  a2 s. co  m*/

        System.out.println("STARTING HelloSmartsheet...");
        //Create a BufferedReader to read user input.
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        System.out.print("Enter Smartsheet API access token:");
        String accessToken = in.readLine();
        System.out.println("Fetching list of your sheets...");
        //Create a connection and fetch the list of sheets
        connection = (HttpURLConnection) new URL(GET_SHEETS_URL).openConnection();
        connection.addRequestProperty("Authorization", "Bearer " + accessToken);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String line;
        //Read the response line by line.
        while ((line = reader.readLine()) != null) {
            response.append(line);
        }
        reader.close();
        //Use Jackson to conver the JSON string to a List of Sheets
        List<Sheet> sheets = mapper.readValue(response.toString(), new TypeReference<List<Sheet>>() {
        });
        if (sheets.size() == 0) {
            System.out.println("You don't have any sheets.  Goodbye!");
            return;
        }
        System.out.println("Total sheets: " + sheets.size());
        int i = 1;
        for (Sheet sheet : sheets) {
            System.out.println(i++ + ": " + sheet.name);
        }
        System.out.print("Enter the number of the sheet you want to share: ");

        //Prompt the user to provide the sheet number, the email address, and the access level
        Integer sheetNumber = Integer.parseInt(in.readLine().trim()); //NOTE: for simplicity, error handling and input validation is neglected.
        Sheet chosenSheet = sheets.get(sheetNumber - 1);

        System.out.print("Enter an email address to share " + chosenSheet.getName() + " to: ");
        String email = in.readLine();

        System.out.print("Choose an access level (VIEWER, EDITOR, EDITOR_SHARE, ADMIN) for " + email + ": ");
        String accessLevel = in.readLine();

        //Create a share object
        Share share = new Share();
        share.setEmail(email);
        share.setAccessLevel(accessLevel);

        System.out.println("Sharing " + chosenSheet.name + " to " + email + " as " + accessLevel + ".");

        //Create a connection. Note the SHARE_SHEET_URL uses /sheet as opposed to /sheets (with an 's')
        connection = (HttpURLConnection) new URL(SHARE_SHEET_URL.replace(SHEET_ID, "" + chosenSheet.getId()))
                .openConnection();
        connection.setDoOutput(true);
        connection.addRequestProperty("Authorization", "Bearer " + accessToken);
        connection.addRequestProperty("Content-Type", "application/json");

        OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
        //Serialize the Share object
        writer.write(mapper.writeValueAsString(share));
        writer.close();

        //Read the response and parse the JSON
        reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        response = new StringBuilder();
        while ((line = reader.readLine()) != null) {
            response.append(line);
        }

        Result result = mapper.readValue(response.toString(), Result.class);
        System.out.println("Sheet shared successfully, share ID " + result.result.id);
        System.out.println("Press any key to quit.");
        in.read();

    } catch (IOException e) {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(((HttpURLConnection) connection).getErrorStream()));
        String line;
        try {
            response = new StringBuilder();
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            reader.close();
            Result result = mapper.readValue(response.toString(), Result.class);
            System.out.println(result.message);
        } catch (IOException e1) {
            e1.printStackTrace();
        }

    } catch (Exception e) {
        System.out.println("Something broke: " + e.getMessage());
        e.printStackTrace();
    }

}

From source file:FormatStorage.TestFormatDataFile.java

public static void main(String[] argv) throws Exception {

    try {//from  ww w  . j av  a  2  s.c  om
        FieldMap fieldMap = new FieldMap();
        fieldMap.addField(new Field(ConstVar.FieldType_Byte, ConstVar.Sizeof_Byte, (short) 1));
        fieldMap.addField(new Field(ConstVar.FieldType_Short, ConstVar.Sizeof_Short, (short) 3));
        fieldMap.addField(new Field(ConstVar.FieldType_Int, ConstVar.Sizeof_Int, (short) 5));
        fieldMap.addField(new Field(ConstVar.FieldType_Long, ConstVar.Sizeof_Long, (short) 7));
        fieldMap.addField(new Field(ConstVar.FieldType_Float, ConstVar.Sizeof_Float, (short) 9));
        fieldMap.addField(new Field(ConstVar.FieldType_Double, ConstVar.Sizeof_Double, (short) 11));
        fieldMap.addField(new Field(ConstVar.FieldType_String, 0, (short) 13));

        head.setFieldMap(fieldMap);

        getRecordByLine();

    } catch (IOException e) {
        e.printStackTrace();
        System.out.println("get IOException:" + e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("get exception:" + e.getMessage());
    }
}

From source file:com.termmed.utils.ResourceUtils.java

/**
 * The main method.//from w  w  w  .  java  2s  .com
 *
 * @param args the arguments
 */
public static void main(final String[] args) {
    //      Pattern pattern;
    //      if(args.length < 1){
    //         pattern = Pattern.compile(".*");
    //      } else{
    //         pattern = Pattern.compile(args[0]);
    //      }
    //      final Collection<String> list = ResourceUtils.getResources(pattern);
    Collection<String> list;
    try {
        String path = "org/ihtsdo/utils/";
        list = ResourceUtils.getResourceScripts(path);
        for (final String file : list) {
            if (file.startsWith(".")) {
                continue;
            }
            String script = FileHelper.getTxtResourceContent(path + "/" + file);
            System.out.println(script);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:au.edu.unsw.cse.soc.federatedcloud.user.CloudBaseUserInterface.java

public static void main(String[] args) {
    CloudBaseUserInterface interfaze = new CloudBaseUserInterface();

    String command;//from   ww w .  ja v a 2  s .com
    try {
        command = args[0];
        if ("init".equals(command)) {
            String appName = args[1];
            try {
                String appAttributes = args[2];
                interfaze.initCloudBase(appName, appAttributes);
            } catch (ArrayIndexOutOfBoundsException aie) {
                log.warn("No attributes specified.");
                interfaze.initCloudBase(appName);
            }

        } else if ("deploy".equals(command)) {
            String resourceName = args[1];
            String resourceMetaData = args[2];
            interfaze.deployResource(resourceName, resourceMetaData);
        } else if ("undeploy".equals(command)) {
            String resourceName = args[1];
            interfaze.undeployResource(resourceName);
        } else {
            System.err.println("Command: " + command + " is not specified.");
        }
    } catch (ArrayIndexOutOfBoundsException ex) {
        System.err.println("please specify a command.");
        log.error(ex.getMessage(), ex);
    } catch (IOException e) {
        System.err.println(e.getMessage());
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

}

From source file:de.bamamoto.mactools.png2icns.Scaler.java

public static void main(String[] args) {

    Options options = new Options();
    options.addOption("i", "input-filename", true,
            "Filename ofthe image containing the icon. The image should be a square with at least 1024x124 pixel in PNG format.");
    options.addOption("o", "iconset-foldername", true,
            "Name of the folder where the iconset will be stored. The extension .iconset will be added automatically.");
    String folderName;//from   w  w  w  . j a  v a2s. c  om
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;

    try {
        cmd = parser.parse(options, args);
        if (cmd.hasOption("i")) {
            if (new File(cmd.getOptionValue("i")).isFile()) {

                if (cmd.hasOption("o")) {
                    folderName = cmd.getOptionValue("o");
                } else {
                    folderName = "/tmp/noname.iconset";
                }

                if (!folderName.endsWith(".iconset")) {
                    folderName = folderName + ".iconset";
                }
                new File(folderName).mkdirs();

                BufferedImage source = ImageIO.read(new File(cmd.getOptionValue("i")));
                BufferedImage resized = resize(source, 1024, 1024);
                save(resized, folderName + "/icon_512x512@2x.png");
                resized = resize(source, 512, 512);
                save(resized, folderName + "/icon_512x512.png");
                save(resized, folderName + "/icon_256x256@2x.png");

                resized = resize(source, 256, 256);
                save(resized, folderName + "/icon_256x256.png");
                save(resized, folderName + "/icon_128x128@2x.png");

                resized = resize(source, 128, 128);
                save(resized, folderName + "/icon_128x128.png");

                resized = resize(source, 64, 64);
                save(resized, folderName + "/icon_32x32@2x.png");

                resized = resize(source, 32, 32);
                save(resized, folderName + "/icon_32x32.png");
                save(resized, folderName + "/icon_16x16@2x.png");

                resized = resize(source, 16, 16);
                save(resized, folderName + "/icon_16x16.png");

                Scaler.runProcess(new String[] { "/usr/bin/iconutil", "-c", "icns", folderName });
            }
        }

    } catch (IOException e) {
        System.out.println("Error reading image: " + cmd.getOptionValue("i"));
        e.printStackTrace();

    } catch (ParseException ex) {
        Logger.getLogger(Scaler.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.mvdb.etl.actions.ExtractDBChanges.java

public static void main(String[] args) throws JSONException {

    ActionUtils.setUpInitFileProperty();
    //        boolean success = ActionUtils.markActionChainBroken("Just Testing");        
    //        System.exit(success ? 0 : 1);
    ActionUtils.assertActionChainNotBroken();
    ActionUtils.assertEnvironmentSetupOk();
    ActionUtils.assertFileExists("~/.mvdb", "~/.mvdb missing. Existing.");
    ActionUtils.assertFileExists("~/.mvdb/status.InitCustomerData.complete",
            "300init-customer-data.sh not executed yet. Exiting");
    //This check is not required as data can be modified any number of times
    //ActionUtils.assertFileDoesNotExist("~/.mvdb/status.ModifyCustomerData.complete", "ModifyCustomerData already done. Start with 100init.sh if required. Exiting");

    ActionUtils.createMarkerFile("~/.mvdb/status.ExtractDBChanges.start", true);

    //String schemaDescription = "{ 'root' : [{'table' : 'orders', 'keyColumn' : 'order_id', 'updateTimeColumn' : 'update_time'}]}";

    String customerName = null;//www  .  j av a 2  s .co m
    final CommandLineParser cmdLinePosixParser = new PosixParser();
    final Options posixOptions = constructPosixOptions();
    CommandLine commandLine;
    try {
        commandLine = cmdLinePosixParser.parse(posixOptions, args);
        if (commandLine.hasOption("customer")) {
            customerName = commandLine.getOptionValue("customer");
        }
    } catch (ParseException parseException) // checked exception
    {
        System.err.println(
                "Encountered exception while parsing using PosixParser:\n" + parseException.getMessage());
    }

    if (customerName == null) {
        System.err.println("Could not find customerName. Aborting...");
        System.exit(1);
    }

    ApplicationContext context = Top.getContext();

    final OrderDAO orderDAO = (OrderDAO) context.getBean("orderDAO");
    final ConfigurationDAO configurationDAO = (ConfigurationDAO) context.getBean("configurationDAO");
    final GenericDAO genericDAO = (GenericDAO) context.getBean("genericDAO");
    File snapshotDirectory = getSnapshotDirectory(configurationDAO, customerName);
    try {
        FileUtils.writeStringToFile(new File("/tmp/etl.extractdbchanges.directory.txt"),
                snapshotDirectory.getName(), false);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
        return;
    }
    long currentTime = new Date().getTime();
    Configuration lastRefreshTimeConf = configurationDAO.find(customerName, "last-refresh-time");
    Configuration schemaDescriptionConf = configurationDAO.find(customerName, "schema-description");
    long lastRefreshTime = Long.parseLong(lastRefreshTimeConf.getValue());
    OrderJsonFileConsumer orderJsonFileConsumer = new OrderJsonFileConsumer(snapshotDirectory);
    Map<String, ColumnMetadata> metadataMap = orderDAO.findMetadata();
    //write file schema-orders.dat in snapshotDirectory
    genericDAO.fetchMetadata("orders", snapshotDirectory);
    //writes files: header-orders.dat, data-orders.dat in snapshotDirectory
    JSONObject json = new JSONObject(schemaDescriptionConf.getValue());
    JSONArray rootArray = json.getJSONArray("root");
    int length = rootArray.length();
    for (int i = 0; i < length; i++) {
        JSONObject jsonObject = rootArray.getJSONObject(i);
        String table = jsonObject.getString("table");
        String keyColumnName = jsonObject.getString("keyColumn");
        String updateTimeColumnName = jsonObject.getString("updateTimeColumn");
        System.out.println("table:" + table + ", keyColumn: " + keyColumnName + ", updateTimeColumn: "
                + updateTimeColumnName);
        genericDAO.fetchAll2(snapshotDirectory, new Timestamp(lastRefreshTime), table, keyColumnName,
                updateTimeColumnName);
    }

    //Unlikely failure
    //But Need to factor this into a separate task so that extraction does not have to be repeated. 
    //Extraction is an expensive task. 
    try {
        String sourceDirectoryAbsolutePath = snapshotDirectory.getAbsolutePath();

        File sourceRelativeDirectoryPath = getRelativeSnapShotDirectory(configurationDAO,
                sourceDirectoryAbsolutePath);
        String hdfsRoot = ActionUtils.getConfigurationValue(ConfigurationKeys.GLOBAL_CUSTOMER,
                ConfigurationKeys.GLOBAL_HDFS_ROOT);
        String targetDirectoryFullPath = hdfsRoot + "/data" + sourceRelativeDirectoryPath;

        ActionUtils.copyLocalDirectoryToHdfsDirectory(sourceDirectoryAbsolutePath, targetDirectoryFullPath);
        String dirName = snapshotDirectory.getName();
        ActionUtils.setConfigurationValue(customerName, ConfigurationKeys.LAST_COPY_TO_HDFS_DIRNAME, dirName);
    } catch (Throwable e) {
        e.printStackTrace();
        logger.error("Objects Extracted from database. But copy of snapshot directory<"
                + snapshotDirectory.getAbsolutePath() + "> to hdfs <" + ""
                + ">failed. Fix the problem and redo extract.", e);
        System.exit(1);
    }

    //Unlikely failure
    //But Need to factor this into a separate task so that extraction does not have to be repeated. 
    //Extraction is an expensive task. 
    String targetZip = null;
    try {
        File targetZipDirectory = new File(snapshotDirectory.getParent(), "archives");
        if (!targetZipDirectory.exists()) {
            boolean success = targetZipDirectory.mkdirs();
            if (success == false) {
                logger.error("Objects copied to hdfs. But able to create archive directory <"
                        + targetZipDirectory.getAbsolutePath() + ">. Fix the problem and redo extract.");
                System.exit(1);
            }
        }
        targetZip = new File(targetZipDirectory, snapshotDirectory.getName() + ".zip").getAbsolutePath();
        ActionUtils.zipFullDirectory(snapshotDirectory.getAbsolutePath(), targetZip);
    } catch (Throwable e) {
        e.printStackTrace();
        logger.error("Objects copied to hdfs. But zipping of snapshot directory<"
                + snapshotDirectory.getAbsolutePath() + "> to  <" + targetZip
                + ">failed. Fix the problem and redo extract.", e);
        System.exit(1);
    }

    //orderDAO.findAll(new Timestamp(lastRefreshTime), orderJsonFileConsumer);
    Configuration updateRefreshTimeConf = new Configuration(customerName, "last-refresh-time",
            String.valueOf(currentTime));
    configurationDAO.update(updateRefreshTimeConf, String.valueOf(lastRefreshTimeConf.getValue()));
    ActionUtils.createMarkerFile("~/.mvdb/status.ExtractDBChanges.complete", true);

}

From source file:com.musicg.experiment.test.Test1.java

/**
 * @param args/*  w  w w .  java  2s.  co m*/
 */
public static void main(String[] args) {

    String filename = "audio_work/lala.wav";

    // create a wave object
    Wave wave = null;
    try {
        wave = new Wave(filename);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // TimeDomainRepresentations
    int fftSampleSize = 1024;
    int overlapFactor = 1;
    Spectrogram spectrogram = new Spectrogram(wave, fftSampleSize, overlapFactor);

    int fps = spectrogram.getFramesPerSecond();
    double unitFrequency = spectrogram.getUnitFrequency();

    // set boundary
    int highPass = 100;
    int lowerBoundary = (int) (highPass / unitFrequency);
    int lowPass = 4000;
    int upperBoundary = (int) (lowPass / unitFrequency);
    // end set boundary

    double[][] spectrogramData = spectrogram.getNormalizedSpectrogramData();
    double[][] absoluteSpectrogramData = spectrogram.getAbsoluteSpectrogramData();
    double[][] boundedSpectrogramData = new double[spectrogramData.length][];

    // SpectralCentroid sc=new SpectralCentroid();
    StandardDeviation sd = new StandardDeviation();
    ArrayRankDouble arrayRankDouble = new ArrayRankDouble();

    // zrc
    short[] amps = wave.getSampleAmplitudes();
    int numFrame = amps.length / 1024;
    double[] zcrs = new double[numFrame];

    for (int i = 0; i < numFrame; i++) {
        short[] temp = new short[1024];
        System.arraycopy(amps, i * 1024, temp, 0, temp.length);

        int numZC = 0;
        int size = temp.length;

        for (int j = 0; j < size - 1; j++) {
            if ((temp[j] >= 0 && temp[j + 1] < 0) || (temp[j] < 0 && temp[j + 1] >= 0)) {
                numZC++;
            }
        }

        zcrs[i] = numZC;
    }

    // end zcr

    for (int i = 0; i < spectrogramData.length; i++) {
        double[] temp = new double[upperBoundary - lowerBoundary + 1];
        System.arraycopy(spectrogramData[i], lowerBoundary, temp, 0, temp.length);

        int maxIndex = arrayRankDouble.getMaxValueIndex(temp);
        // sc.setValues(temp);

        double sdValue = sd.evaluate(temp);

        System.out.println(i + " " + (double) i / fps + "s\t" + maxIndex + "\t" + sdValue + "\t" + zcrs[i]);
        boundedSpectrogramData[i] = temp;
    }

    // Graphic render
    GraphicRender render = new GraphicRender();
    render.setHorizontalMarker(61);
    render.setVerticalMarker(200);
    render.renderSpectrogramData(boundedSpectrogramData, filename + ".jpg");

    PitchHandler ph = new PitchHandler();

    for (int frame = 0; frame < absoluteSpectrogramData.length; frame++) {

        System.out.print("frame " + frame + ": ");

        double[] temp = new double[upperBoundary - lowerBoundary + 1];

        double sdValue = sd.evaluate(temp);
        double passSd = 0.1;

        if (sdValue < passSd) {
            System.arraycopy(spectrogramData[frame], lowerBoundary, temp, 0, temp.length);
            double maxFrequency = arrayRankDouble.getMaxValueIndex(temp) * unitFrequency;

            double passFrequency = 400;
            int numRobust = 2;

            double[] robustFrequencies = new double[numRobust];
            double nthValue = arrayRankDouble.getNthOrderedValue(temp, numRobust, false);
            int count = 0;
            for (int b = lowerBoundary; b <= upperBoundary; b++) {
                if (spectrogramData[frame][b] >= nthValue) {
                    robustFrequencies[count++] = b * unitFrequency;
                    if (count >= numRobust) {
                        break;
                    }
                }
            }

            double passIntensity = 1000;
            double intensity = 0;
            for (int i = 0; i < absoluteSpectrogramData[frame].length; i++) {
                intensity += absoluteSpectrogramData[frame][i];
            }
            intensity /= absoluteSpectrogramData[frame].length;
            System.out.print(" intensity: " + intensity + " pitch: " + maxFrequency);
            if (intensity > passIntensity && maxFrequency > passFrequency) {
                double p = ph.getHarmonicProbability(robustFrequencies);
                System.out.print(" P: " + p);
            }
        }
        System.out.print(" zcr:" + zcrs[frame]);
        System.out.println();
    }
}

From source file:com.honnix.yaacs.adapter.http.ui.ACHttpClientCli.java

public static void main(String[] args) {
    ACHttpClientCli acHttpClientCli = new ACHttpClientCli();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while (true) {
        acHttpClientCli.help();/*from   ww  w  .j a  va 2 s. c  o m*/

        String cmd = null;

        try {
            cmd = br.readLine();
        } catch (IOException e) {
            e.printStackTrace(); // NOPMD by honnix on 3/29/08 10:35 PM
            System.err.println(BAD_INPUT); // NOPMD by honnix on 3/29/08 10:35 PM

            continue;
        }

        if ("li".equals(cmd)) {
            try {
                acHttpClientCli.handleLogin(br);
            } catch (Exception e) {
                e.printStackTrace(); // NOPMD by honnix on 3/29/08 10:35 PM
                System.err.println("Error logging in."); // NOPMD by honnix on 3/29/08 10:35 PM
            }
        } else if ("lo".equals(cmd)) {
            try {
                acHttpClientCli.handleLogout();
            } catch (Exception e) {
                e.printStackTrace(); // NOPMD by honnix on 3/29/08 10:35 PM
                System.err.println("Error logging out."); // NOPMD by honnix on 3/29/08 10:35 PM
            }
        }
        if ("p".equals(cmd)) {
            try {
                acHttpClientCli.handlePut(br);
            } catch (Exception e) {
                e.printStackTrace(); // NOPMD by honnix on 3/29/08 10:35 PM
                System.err.println("Error putting album cover."); // NOPMD by honnix on 3/29/08 10:36 PM
            }
        } else if ("r".equals(cmd)) {
            try {
                acHttpClientCli.handleRetrieve(br);
            } catch (Exception e) {
                e.printStackTrace(); // NOPMD by honnix on 3/29/08 10:35 PM
                System.err.println("Error retrieving album cover list."); // NOPMD by honnix on 3/29/08 10:36 PM
            }
        } else if ("q".equals(cmd)) {
            break;
        }
    }
}