Example usage for java.lang String String

List of usage examples for java.lang String String

Introduction

In this page you can find the example usage for java.lang String String.

Prototype

public String() 

Source Link

Document

Initializes a newly created String object so that it represents an empty character sequence.

Usage

From source file:db.Db.java

public static void main(String[] args) throws InterruptedException, Exception {
    // TODO code application logic here

    //SETUP/*  www  .j av a 2 s.  c  om*/
    WebDriver driver;
    String referralUrl, accounts[][];
    String mSuffix = new String();

    double space = 0, nAccounts;
    int needAccounts, creAccounts, f;
    StringBuffer verificationErrors = new StringBuffer();
    driver = new FirefoxDriver();
    //        driver = new HtmlUnitDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    referralUrl = "https://www.dropbox.com/referrals/NTM2OTAyMjIyMjk?src=global9";
    mSuffix = "@gmail.com";
    space = 16.250;
    space = (Math.floor(space * 2) / 2); //trunk number to .0 or .5

    needAccounts = (int) ((18 - space) * 2); //number of accounts needed
    creAccounts = 0; //number of accounts created
    accounts = new String[needAccounts][4]; //accounts credentials matrix

    //GENERATE ACCOUNTS

    for (f = 0; f < accounts.length; f++)
        genAccount(accounts, mSuffix, f);

    //REGISTER
    int regAttempts = 0;
    System.out.print("Registering accounts => ");
    for (f = 0; f < accounts.length; f++) {
        while (!regAccount(accounts, referralUrl, f, driver) && regAttempts < 3) {

            regAttempts++;
            genAccount(accounts, mSuffix, f);
        }
        if (regAttempts < 3)
            creAccounts++;
        else
            System.out.println("Registration failed 3 consecutive times. Aborting");

    } //end for

    if (creAccounts == needAccounts)
        System.out.println("\n" + creAccounts + " DROPBOX ACCOUNTS CREATED SUCCESFULLY!!  :D :D");

    //TEARDOWN
    driver.quit();

}

From source file:BrokerFrame.java

/**
 * @param args the command line arguments
 *///  w  ww.  ja v a  2  s .  c o  m
public static void main(String args[]) throws Exception {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(BrokerFrame.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>

    String ola = new String();
    ola = "olajjhgjhhjkhjkhjhkjhjhgg";

    RSA rs = new RSA();
    rs.generateKeys();
    System.out.println((RSA.privKey).toString());
    byte[] signature = rs.encrypt(ola, RSA.privKey);
    String sig = new Base64().encodeAsString(signature);
    byte[] byt = new Base64().decode(sig);
    System.out.println(sig);
    try {
        rs.verifySignature(ola.getBytes(), signature);
    } catch (Exception e) {
        throw new Exception(e);
    }
    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new BrokerFrame().setVisible(true);
        }
    });
}

From source file:mmllabvsdextractfeature.MMllabVSDExtractFeature.java

/**
 * @param args the command line arguments
 *///from ww w  .j  a va2 s  . c o m
public static void main(String[] args) throws IOException {
    // TODO code application logic here
    MMllabVSDExtractFeature hello = new MMllabVSDExtractFeature();
    FileStructer metdata = new FileStructer();
    //Utility utilityClassIni = new Utility();
    FrameStructer frameStructer = new FrameStructer();

    /*
    Flow :
            
    1. Read  metdata file
    2. Untar folder:
        -1 Shot content 25 frame
        -1 folder 50 shot
    Process with 1 shot:
        - Resize All image 1 shot --> delete orginal.
        - Extract feature 25 frame
        - Pooling Max and aveg.
        - Delete Image, feature
        - zip file Feature 
    3. Delete File.
                
    */

    // Load metadata File
    String dir = "/media/data1";
    String metadataFileDir = "/media/data1/metdata/devel2011-new.lst";
    ArrayList<FileStructer> listFileFromMetadata = metdata.readMetadata(metadataFileDir);

    //        String test = utilityClass.readTextFile("C:\\Users\\tiendv\\Downloads\\VSD_devel2011_1.shot_1.RKF_1.Frame_1.txt");
    //        ArrayList <String> testFeatureSave = utilityClass.SplitUsingTokenizerWithLineArrayList(test, " ");
    //        utilityClass.writeToFile("C:\\Users\\tiendv\\Downloads\\VSD_devel2011_1.shot_1.txt", testFeatureSave);
    //        System.out.println(test);

    for (int i = 0; i < listFileFromMetadata.size(); i++) {

        Utility utilityClass = new Utility();
        //Un zip file
        String folderName = listFileFromMetadata.get(i).getWholeFolderName();
        String nameZipFile = dir + "/" + folderName + "/" + listFileFromMetadata.get(i).getNameZipFileName()
                + ".tar";
        nameZipFile = nameZipFile.replaceAll("\\s", "");
        String outPutFolder = dir + "/" + folderName + "/" + listFileFromMetadata.get(i).getNameZipFileName();
        outPutFolder = outPutFolder.replaceAll("\\s", "");
        utilityClass.unTarFolder(UNTARSHFILE, nameZipFile, outPutFolder + "_");

        // Resize all image in folder has been unzip
        utilityClass.createFolder(CREADFOLDER, outPutFolder);
        utilityClass.resizeWholeFolder(outPutFolder + "_", outPutFolder, resizeWidth, resizeHeight);
        utilityClass.deleteWholeFolder(DELETEFOLDER, outPutFolder + "_");
        // Read all file from Folder has been unzip

        ArrayList<FrameStructer> allFrameInZipFolder = new ArrayList<>();
        allFrameInZipFolder = frameStructer.getListFileInZipFolder(outPutFolder);
        System.out.println(allFrameInZipFolder.size());
        // sort with shot ID
        Collections.sort(allFrameInZipFolder, FrameStructer.frameIDNo);

        // Loop with 1 shot
        int indexFrame = 0;
        for (int n = 0; n < allFrameInZipFolder.size() / 25; n++) {
            // Process with 1 
            ArrayList<String> nameAllFrameOneShot = new ArrayList<>();
            String shotAndFolderName = new String();
            for (; indexFrame < Math.min((n + 1) * 25, allFrameInZipFolder.size()); indexFrame++) {
                String imageForExtract = outPutFolder + "/" + allFrameInZipFolder.get(indexFrame).toFullName()
                        + ".jpg";
                shotAndFolderName = allFrameInZipFolder.get(indexFrame).shotName();
                String resultNameAfterExtract = outPutFolder + "/"
                        + allFrameInZipFolder.get(indexFrame).toFullName() + ".txt";
                nameAllFrameOneShot.add(resultNameAfterExtract);
                // extract and Delete image file --> ouput image'feature
                utilityClass.excuteFeatureExtractionAnImage(EXTRACTFEATUREANDDELETESOURCEIMAGESHFILE, "0",
                        CUDAOVERFEATPATH, imageForExtract, resultNameAfterExtract);
            }
            // Pooling 

            //                    DenseMatrix64F resultMaTrixFeatureOneShot = utilityClass.buidEJMLMatrixFeatureOneShot(nameAllFrameOneShot);
            //                    utilityClass.savePoolingFeatureOneShotWithEJMLFromMatrix(resultMaTrixFeatureOneShot,outPutFolder,shotAndFolderName);

            utilityClass.buidPoolingFileWithOutMatrixFeatureOneShot(nameAllFrameOneShot, outPutFolder,
                    shotAndFolderName);
            // Save A file 

            for (int frameCount = 0; frameCount < nameAllFrameOneShot.size(); frameCount++) { // Delete feature extract file
                utilityClass.deletefile(DELETEFILE, nameAllFrameOneShot.get(frameCount));
            }
            // Release one shot data
            nameAllFrameOneShot.clear();
            System.out.print("The end of one's shot" + "\n" + n);
        }
        // Delete zip file
        utilityClass.deletefile(DELETEFILE, nameZipFile);

        // Zip Whole Folder

        /**
         * Extract 1 shot
         * Resize 25 frame with the same shotid --> delete orgra.
         * Extract 25 frame --> feature file --->delete 
         * 
         */

    }

}

From source file:Utils.java

public final static String removeChar(String str, char c) {
    String output = new String();
    for (int i = 0; i < str.length(); i++) {
        if (str.charAt(i) != c)
            output += str.charAt(i);//ww w.j  ava2  s  . c o m
    }
    return output;
}

From source file:Main.java

public static String showPrintable(byte[] ra) {
    String s = new String();
    for (int i = 0; i < ra.length; i++) {
        char c = (char) ra[i];
        if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
            s = s + c;//from  w  w  w . jav  a2  s.c om
        } else {
            s = s + '.';
        }
    }
    return s;
}

From source file:Main.java

private static int gbValue(char paramChar) {
    String str = new String() + paramChar;
    try {/*  ww w. ja  v  a  2s. c o  m*/
        byte[] arrayOfByte = str.getBytes("GB2312");
        if (arrayOfByte.length < 2)
            return 0;
        int i = 0xFF00 & arrayOfByte[0] << 8;
        int j = arrayOfByte[1];
        return i + (j & 0xFF);
    } catch (Exception localException) {
    }
    return 0;
}

From source file:Main.java

public static String getHexString(byte[] raw) {
    String str = new String();

    for (byte b : raw) {
        String hex = Integer.toHexString(b & 0xFF);

        if (hex.length() == 1) {
            str += "0" + hex;
        } else {//from  www  .  ja v a  2  s  . com
            str += hex;
        }
    }

    return str;
}

From source file:Main.java

public static String formatNumber(int number) {

    String string = new String();

    if (number < 10) {
        string = "00" + number;
    } else if (number >= 10 && number < 100) {
        string = "0" + number;
    } else {/*from w  w w.  ja v a 2s .  c o  m*/
        string = String.valueOf(number);
    }

    return string;
}

From source file:Main.java

public static String getTimeFormat(String timestr) {

    String datetimestr = new String();

    datetimestr = timestr.substring(5, 7);

    datetimestr = datetimestr.concat("/");

    datetimestr = datetimestr.concat(timestr.substring(8, 10));

    datetimestr = datetimestr.concat(" ");

    datetimestr = datetimestr.concat(timestr.substring(11, 16));

    return datetimestr;

}

From source file:Main.java

public static String createImportSentence(String fileName, boolean isPublic) {
    String ret = new String();
    if (isPublic) {
        ret = "#import <" + fileName + ">";
    } else {/*w w  w . jav a2  s .c  o m*/
        ret = "#import \"" + fileName + "\"";
    }
    return ret;
}