Example usage for java.lang System in

List of usage examples for java.lang System in

Introduction

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

Prototype

InputStream in

To view the source code for java.lang System in.

Click Source Link

Document

The "standard" input stream.

Usage

From source file:cn.lhfei.hadoop.ch04.PooledStreamCompressor.java

/**
 * use case: /*from w  w  w  . j a  v a  2  s.co m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    String codecClassname = args[0];
    Class<?> codecClass = null;
    CompressionOutputStream out = null;
    Compressor compressor = null;
    try {
        codecClass = Class.forName(codecClassname);
        Configuration conf = new Configuration();
        CompressionCodec codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, conf);
        compressor = CodecPool.getCompressor(codec);

        out = codec.createOutputStream(System.out, compressor);

        IOUtils.copyBytes(System.in, out, 4096, false);

        out.finish();

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        CodecPool.returnCompressor(compressor);
    }
}

From source file:bundestagswahl.benchmark.BWBenchmark.java

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

    resultTime = new double[6];

    Scanner scanner = new Scanner(System.in);
    System.out.print("Please enter URL: ");
    serverUrl = scanner.nextLine();/*from ww  w  . ja va  2s .c  om*/
    System.out.print("Please enter number of terminals: ");
    numberTerminals = scanner.nextInt();
    System.out.print("Please enter number of requests: ");
    numberRequests = scanner.nextInt();
    System.out.print("Please enter delay between two requests in seconds: ");
    requestDelay = scanner.nextDouble();
    scanner.close();

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
    cm.setMaxTotal(numberTerminals);
    HttpClient httpclient = new DefaultHttpClient(cm);
    httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 300000)
            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 300000)
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
    try {
        final CountDownLatch latch = new CountDownLatch(numberTerminals);
        for (int i = 0; i < numberTerminals; i++) {
            BenchmarkTerminal terminal = new BenchmarkTerminal(httpclient, latch, serverUrl, numberRequests,
                    requestDelay);
            terminal.start();
        }
        latch.await();
        httpclient.getConnectionManager().shutdown();
    } finally {

    }

    printResultTimes();
    System.out.println(" ");
    System.out.println("Done");
}

From source file:org.jfree.chart.demo.Display.java

/**
 * Launch the application.//  www .  jav  a2s. com
 */
public static void main(String[] args) throws IOException {

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Display window = new Display();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
            ////////////
        }
    });

    try {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s;
        File dataFile = new File("data.txt");
        FileWriter fw = new FileWriter(dataFile);
        BufferedWriter bw = new BufferedWriter(fw);
        DataParser datIn = new DataParser(effectiveX, effectiveY);

        //while(!enabled){}//spin until enabled

        while ((s = in.readLine()) != null && s.length() != 0 && enabled) {
            // System.out.println(s);
            if (datIn.parseString(s)) {
                bw.write(s);
                bw.write('\n');
                bw.flush();
                panel_1.plotCoords(datIn.getX(), datIn.getFlippedY());
                TimeElapsed.setText(Double.toString(datIn.getTime()));
            }
        }

        bw.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.balero.test.Wizard.java

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    System.out.println(""
            + ".-. .-')     ('-.                 ('-.  _  .-')                                _   .-')      .-')    \n"
            + "\\  ( OO )   ( OO ).-.           _(  OO)( \\( -O )                              ( '.( OO )_   ( OO ). \n"
            + " ;-----.\\   / . --. / ,--.     (,------.,------.  .-'),-----.          .-----. ,--.   ,--.)(_)---\\_) \n"
            + " | .-.  |   | \\-.  \\  |  |.-')  |  .---'|   /`. '( OO'  .-.  '        '  .--./ |   `.'   | /    _ |  \n"
            + " | '-' /_).-'-'  |  | |  | OO ) |  |    |  /  | |/   |  | |  |        |  |('-. |         | \\  :` `.  \n"
            + " | .-. `.  \\| |_.'  | |  |`-' |(|  '--. |  |_.' |\\_) |  |\\|  |       /_) |OO  )|  |'.'|  |  '..`''.) \n"
            + " | |  \\  |  |  .-.  |(|  '---.' |  .--' |  .  '.'  \\ |  | |  |       ||  |`-'| |  |   |  | .-._)   \\ \n"
            + " | '--'  /  |  | |  | |      |  |  `---.|  |\\  \\    `'  '-'  '      (_'  '--'\\ |  |   |  | \\       / \n"
            + " `------'   `--' `--' `------'  `------'`--' '--'     `-----'          `-----' `--'   `--'  `-----'  \n"
            + "                                                                                  Enterprise Edition\n");
    System.out.println("Welcome to Balero CMS Setup Wizard\n");
    System.out.println("Provide your Database configuration.\n");

    String dbuser;//from   w  w  w  . j  a v  a2  s.  c o  m
    System.out.print("Insert MySQL Username\n");
    dbuser = sc.nextLine();

    String dbpass;
    System.out.print("Insert MySQL Password\n");
    dbpass = sc.nextLine();

    String opt;
    System.out.println("The MIT License (MIT)\n" + "\n" + "Copyright (c) 2014 Balero CMS Enterprise Edition.\n"
            + "\n" + "Permission is hereby granted, free of charge, to any person obtaining a copy\n"
            + "of this software and associated documentation files (the \"Software\"), to deal\n"
            + "in the Software without restriction, including without limitation the rights\n"
            + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n"
            + "copies of the Software, and to permit persons to whom the Software is\n"
            + "furnished to do so, subject to the following conditions:\n" + "\n"
            + "The above copyright notice and this permission notice shall be included in\n"
            + "all copies or substantial portions of the Software.\n" + "\n"
            + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
            + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
            + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
            + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
            + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"
            + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" + "THE SOFTWARE.\n"
            + "Agree: Enter Decline: e");
    opt = sc.nextLine();
    exitWizard(opt);

    System.out.print("Setup wizard will create database tables\n" + "Continue: Enter or Exit: e\n");
    opt = sc.nextLine();
    exitWizard(opt);

    try {

        System.out.println("" + "     _( )_          _      Mounting CMS...\n" + "   _(     )_      _( )_\n"
                + "  (_________)   _(     )_\n" + "               (_________)\n"
                + "    0  1  0               \n" + "       1  0     0  1  0\n" + "          1       1  0");
        ;

        for (double progressPercentage = 0.0; progressPercentage < 1.0; progressPercentage += 0.01) {
            updateProgress(progressPercentage);
            Thread.sleep(100);
        }
    } catch (InterruptedException e) {

    }

}

From source file:com.alibaba.dubbo.examples.async.AsyncConsumer.java

public static void main(String[] args) throws Exception {
    String config = AsyncConsumer.class.getPackage().getName().replace('.', '/') + "/async-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();/*from  w w w  . ja  v  a  2  s. c o  m*/

    final AsyncService asyncService = (AsyncService) context.getBean("asyncService");

    Future<String> f = RpcContext.getContext().asyncCall(new Callable<String>() {
        public String call() throws Exception {
            return asyncService.sayHello("async call request");
        }
    });

    System.out.println("async call ret :" + f.get());

    RpcContext.getContext().asyncCall(new Runnable() {
        public void run() {
            asyncService.sayHello("oneway call request1");
            asyncService.sayHello("oneway call request2");
        }
    });

    System.in.read();
}

From source file:com.chargebee.Application.DateFormat.java

public static void main(String[] args) throws IOException, Exception {
    Scanner sc = new Scanner(System.in);
    System.out.println("Input CSV File: ");
    String source = sc.nextLine();

    System.out.println("Input JSON File: ");
    String requirements = sc.nextLine();

    System.out.println("Output CSV File: ");
    String output = sc.nextLine();

    DateFormat df = new DateFormat();
    JSONObject jobj = MethodBank.readJsonObjectData(requirements);
    CSVParser parser = MethodBank.parserInitializer(source);
    CSVPrinter printer = MethodBank.printerInitializer(output);

    df.formatter(parser, printer, jobj);
    parser.close();//from   w w  w  . j  av a  2  s .  c om
    printer.close();

}

From source file:org.keycloak.example.CustomerCli.java

public static void main(String[] args) throws Exception {
    keycloak = new KeycloakInstalled();
    br = new BufferedReader(new InputStreamReader(System.in));

    printHelp();//  w w w. j  a  v a2  s  . co  m
    printDivider();

    System.out.print("$ ");
    for (String s = br.readLine(); s != null; s = br.readLine()) {
        printDivider();

        try {
            if (s.equals("login")) {
                keycloak.login(System.out, br);
                System.out.println("Logged in: " + keycloak.getToken().getSubject());
            } else if (s.equals("logout")) {
                keycloak.logout();
                System.out.println("Logged out");
            } else if (s.equals("login-desktop")) {
                keycloak.loginDesktop();
                System.out.println("Logged in: " + keycloak.getToken().getSubject());
            } else if (s.equals("login-manual")) {
                keycloak.loginManual(System.out, br);
                System.out.println("Logged in: " + keycloak.getToken().getSubject());
            } else if (s.equals("profile")) {
                profile();
            } else if (s.equals("customers")) {
                customers();
            } else if (s.equals("token")) {
                System.out.println(mapper.writeValueAsString(keycloak.getToken()));
            } else if (s.equals("id-token")) {
                System.out.println(mapper.writeValueAsString(keycloak.getIdToken()));
            } else if (s.equals("refresh")) {
                keycloak.refreshToken();
                System.out.println(
                        "Token refreshed: expires at " + Time.toDate(keycloak.getToken().getExpiration()));
            } else if (s.equals("exit")) {
                System.exit(0);
            } else {
                printHelp();
            }
        } catch (ServerRequest.HttpFailure t) {
            System.out.println(t.getError());
        } catch (Throwable t) {
            System.out.println(t.getMessage() != null ? t.getMessage() : t.getClass().toString());
        }
        printDivider();

        System.out.print("$ ");
    }
}

From source file:com.thinkbiganalytics.kerberos.TestKerberosKinit.java

public static void main(String[] args) throws Exception {
    final TestKerberosKinit testKerberosKinit = new TestKerberosKinit();
    Scanner scanner = new Scanner(System.in);

    System.out.println(" ");
    System.out.print("Which environment are you in? Enter 1 for HDP or 2 for Cloudera: ");
    String environmentCode = scanner.nextLine();
    if (StringUtils.isEmpty(environmentCode)) {
        environmentCode = "1";
    }//from   www. j a v  a 2 s . c o  m

    String environment;
    switch (environmentCode) {
    case "1":
        environment = ENVIRONMENT_HDP;
        break;
    case "2":
        environment = ENVIRONMENT_CLOUDERA;
        break;
    default:
        throw new Exception("Invalid environment code");
    }

    System.out.println(" ");
    System.out.println(
            "Hit enter to default to: /etc/hadoop/conf/core-site.xml,/etc/hadoop/conf/hdfs-site.xml,/usr/hdp/current/hive-client/conf/hive-site.xml");
    System.out.print("Please enter the list of configuration resources: ");
    String configResources = scanner.nextLine();
    if (StringUtils.isEmpty(configResources)) {
        configResources = "/etc/hadoop/conf/core-site.xml,/etc/hadoop/conf/hdfs-site.xml,/usr/hdp/current/hive-client/conf/hive-site.xml";
    }

    System.out.println(" ");
    System.out.println("Hit enter to default to: /etc/security/keytabs/hive-thinkbig.headless.keytab");
    System.out.print("Please enter the keytab file location: ");
    String keytab = scanner.nextLine();
    if (StringUtils.isEmpty(keytab)) {
        keytab = "/etc/security/keytabs/hive-thinkbig.headless.keytab";
    }

    System.out.println(" ");
    System.out.println("Hit enter to default to: hive/sandbox.hortonworks.com@sandbox.hortonworks.com");
    System.out.print("Please enter the real user principal name: ");
    String realUserPrincipal = scanner.nextLine();
    if (StringUtils.isEmpty(realUserPrincipal)) {
        realUserPrincipal = "hive/sandbox.hortonworks.com@sandbox.hortonworks.com";
    }

    System.out.println(" ");
    System.out.println("Please enter Y/N (default is N)");
    System.out.print("Do you want to test with a proxy user: ");
    String proxyUser = scanner.nextLine();
    if (StringUtils.isEmpty(realUserPrincipal)) {
        proxyUser = "N";
    }

    System.out.println(" ");
    System.out.println("Hit enter to default to: hdfs://sandbox.hortonworks.com:8020");
    System.out.print("Please enter the HDFS URL: ");
    String hdfsUrl = scanner.nextLine();
    if (StringUtils.isEmpty(hdfsUrl)) {
        hdfsUrl = "hdfs://sandbox.hortonworks.com:8020";
    }

    System.out.println(" ");
    System.out.println("Hit enter to default to: jdbc:hive2://localhost:10000/default");
    System.out.print("Please enter the Hive base connection string: ");
    String hiveHost = scanner.nextLine();
    if (StringUtils.isEmpty(hiveHost)) {
        hiveHost = "jdbc:hive2://localhost:10000/default";
    }

    String proxyUserName = null;
    if ("Y".equalsIgnoreCase(proxyUser)) {
        System.out.println(" ");
        System.out.print("Please enter the proxy user: ");
        proxyUserName = scanner.next();
    }

    System.out.println(" ");
    System.out.println("Executing Kinit to generate a kerberos ticket");

    if ("Y".equalsIgnoreCase(proxyUser)) {
        System.out.println("Testing with the proxy user: " + proxyUserName);
        testKerberosKinit.testHdfsWithUserImpersonation(configResources, keytab, realUserPrincipal,
                proxyUserName, environment, hdfsUrl);

        //testKerberosKinit.testHiveJdbcConnectionWithUserImpersonation(configResources, keytab, realUserPrincipal, proxyUserName);
        testKerberosKinit.testHiveJdbcConnection(configResources, keytab, realUserPrincipal, proxyUserName,
                hiveHost);
    } else {
        System.out.println("No Proxy User");
        testKerberosKinit.testHdfsAsKerberosUser(configResources, keytab, realUserPrincipal, environment,
                hdfsUrl);
        testKerberosKinit.testHiveJdbcConnection(configResources, keytab, realUserPrincipal, null, hiveHost);
    }
}

From source file:ChatClient.java

public static void main(String[] args) throws Exception {
        int PORT = 4000;
        byte[] buf = new byte[1000];
        DatagramPacket dgp = new DatagramPacket(buf, buf.length);
        DatagramSocket sk;/*from   w  w  w .ja  va 2s .c  o  m*/

        sk = new DatagramSocket(PORT);
        System.out.println("Server started");
        while (true) {
            sk.receive(dgp);
            String rcvd = new String(dgp.getData(), 0, dgp.getLength()) + ", from address: " + dgp.getAddress()
                    + ", port: " + dgp.getPort();
            System.out.println(rcvd);

            BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
            String outMessage = stdin.readLine();
            buf = ("Server say: " + outMessage).getBytes();
            DatagramPacket out = new DatagramPacket(buf, buf.length, dgp.getAddress(), dgp.getPort());
            sk.send(out);
        }
    }

From source file:com.mycompany.mavenproject4.NewMain.java

/**
 * @param args the command line arguments
 *///from  w  w  w  .j a v a 2s. c  o m
public static void main(String[] args) {
    System.out.println("Enter your choice do you want to work with 1.postgre 2.Redis 3.Mongodb");
    InputStreamReader IORdatabase = new InputStreamReader(System.in);
    BufferedReader BIOdatabase = new BufferedReader(IORdatabase);
    String databasechoice = null;
    try {
        databasechoice = BIOdatabase.readLine();
    } catch (Exception E7) {
        System.out.println(E7.getMessage());
    }

    // loading data from the CSV file 

    CsvReader Employees = null;

    try {
        Employees = new CsvReader("CSVFile\\Employees.csv");
    } catch (FileNotFoundException EB) {
        System.out.println(EB.getMessage());
    }
    int ColumnCount = 3;
    int RowCount = 100;
    int iloop = 0;

    try {
        Employees = new CsvReader("CSVFile\\Employees.csv");
    } catch (FileNotFoundException E) {
        System.out.println(E.getMessage());
    }

    String[][] Dataarray = new String[RowCount][ColumnCount];
    try {
        while (Employees.readRecord()) {
            String v;
            String[] x;
            v = Employees.getRawRecord();
            x = v.split(",");
            for (int j = 0; j < ColumnCount; j++) {
                String value = null;
                int z = j;
                value = x[z];
                try {
                    Dataarray[iloop][j] = value;
                } catch (Exception E) {
                    System.out.println(E.getMessage());
                }
                // System.out.println(Dataarray[iloop][j]);
            }
            iloop = iloop + 1;
        }
    } catch (IOException Em) {
        System.out.println(Em.getMessage());
    }

    Employees.close();

    // connection to Database 
    switch (databasechoice) {
    // postgre code goes here 
    case "1":

        Connection Conn = null;
        Statement Stmt = null;
        URI dbUri = null;
        String choice = null;
        InputStreamReader objin = new InputStreamReader(System.in);
        BufferedReader objbuf = new BufferedReader(objin);
        try {
            Class.forName("org.postgresql.Driver");
        } catch (Exception E1) {
            System.out.println(E1.getMessage());
        }
        String username = "ldoiarosfrzrua";
        String password = "HBkE_pJpK5mMIg3p2q1_odmEFX";
        String dbUrl = "jdbc:postgresql://ec2-54-83-53-120.compute-1.amazonaws.com:5432/d6693oljh5cco4?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory";

        // now update data in the postgress Database 

        // for(int i=0;i<RowCount;i++)
        // {
        //       try 
        //          {

        //         Conn= DriverManager.getConnection(dbUrl, username, password);    
        //           Stmt = Conn.createStatement();
        //           String Connection_String = "insert into EmployeeDistinct (name,jobtitle,department) values (' "+ Dataarray[i][0]+" ',' "+ Dataarray[i][1]+" ',' "+ Dataarray[i][2]+" ')";
        //         Stmt.executeUpdate(Connection_String);
        //       
        //        }
        //        catch(SQLException E4)
        //         {
        //             System.out.println(E4.getMessage());
        //          }
        // }

        // Quering with the Database 

        System.out.println("1. Display Data ");
        System.out.println("2. Select data based on primary key");
        System.out.println("3. Select data based on Other attributes e.g Name");
        System.out.println("Enter your Choice ");
        try {
            choice = objbuf.readLine();
        } catch (IOException E) {
            System.out.println(E.getMessage());
        }
        switch (choice) {
        case "1":
            try {
                Conn = DriverManager.getConnection(dbUrl, username, password);
                Stmt = Conn.createStatement();
                String Connection_String = " Select * from EmployeeDistinct;";
                ResultSet objRS = Stmt.executeQuery(Connection_String);
                while (objRS.next()) {
                    System.out.println("Employee ID: " + objRS.getInt("EmployeeID"));
                    System.out.println("Employee Name: " + objRS.getString("Name"));
                    System.out.println("Employee City: " + objRS.getString("Jobtitle"));
                    System.out.println("Employee City: " + objRS.getString("Department"));
                }

            } catch (Exception E2) {
                System.out.println(E2.getMessage());
            }

            break;

        case "2":

            System.out.println("Enter the Primary Key");
            InputStreamReader objkey = new InputStreamReader(System.in);
            BufferedReader objbufkey = new BufferedReader(objkey);
            int key = 0;
            try {
                key = Integer.parseInt(objbufkey.readLine());
            } catch (IOException E) {
                System.out.println(E.getMessage());
            }
            try {
                Conn = DriverManager.getConnection(dbUrl, username, password);
                Stmt = Conn.createStatement();
                String Connection_String = " Select * from EmployeeDistinct where EmployeeID=" + key + ";";
                ResultSet objRS = Stmt.executeQuery(Connection_String);
                while (objRS.next()) {
                    System.out.println("Employee Name: " + objRS.getString("Name"));
                    System.out.println("Employee City: " + objRS.getString("Jobtitle"));
                    System.out.println("Employee City: " + objRS.getString("Department"));
                }

            } catch (Exception E2) {
                System.out.println(E2.getMessage());
            }
            break;

        case "3":
            String Name = null;
            System.out.println("Enter Name to find the record");
            InputStreamReader objname = new InputStreamReader(System.in);
            BufferedReader objbufname = new BufferedReader(objname);

            try {
                Name = (objbufname.readLine()).toString();
            } catch (IOException E) {
                System.out.println(E.getMessage());
            }
            try {
                Conn = DriverManager.getConnection(dbUrl, username, password);
                Stmt = Conn.createStatement();
                String Connection_String = " Select * from EmployeeDistinct where Name=" + "'" + Name + "'"
                        + ";";

                ResultSet objRS = Stmt.executeQuery(Connection_String);
                while (objRS.next()) {
                    System.out.println("Employee ID: " + objRS.getInt("EmployeeID"));
                    System.out.println("Employee City: " + objRS.getString("Jobtitle"));
                    System.out.println("Employee City: " + objRS.getString("Department"));
                }

            } catch (Exception E2) {
                System.out.println(E2.getMessage());
            }
            break;
        }
        try {
            Conn.close();
        } catch (SQLException E6) {
            System.out.println(E6.getMessage());
        }
        break;

    // Redis code goes here 

    case "2":
        int Length = 0;
        String ID = null;
        Length = 100;

        // Connection to Redis 
        Jedis jedis = new Jedis("pub-redis-18017.us-east-1-4.6.ec2.redislabs.com", 18017);
        jedis.auth("7EFOisRwMu8zvhin");
        System.out.println("Connected to Redis");

        // Storing values in the database 

        //  System.out.println("Storing values in the Database might take a minute ");

        // for(int i=0;i<Length;i++)
        // { 
        // Store data in redis 
        //     int j=i+1;
        //  jedis.hset("Employe:" + j , "Name", Dataarray[i][0]);
        //   jedis.hset("Employe:" + j , "Jobtitle ", Dataarray[i][1]);
        //  jedis.hset("Employe:" + j , "Department", Dataarray[i][2]);

        //  }

        System.out.println("Search by 1.primary key,2.Name 3.display first 20");
        InputStreamReader objkey = new InputStreamReader(System.in);
        BufferedReader objbufkey = new BufferedReader(objkey);
        String interimChoice1 = null;
        try {
            interimChoice1 = objbufkey.readLine();
        } catch (IOException E) {
            System.out.println(E.getMessage());
        }
        switch (interimChoice1) {
        case "1":
            System.out.print("Get details using the primary Key");
            InputStreamReader IORKey = new InputStreamReader(System.in);
            BufferedReader BIORKey = new BufferedReader(IORKey);
            String ID1 = null;
            try {
                ID1 = BIORKey.readLine();
            } catch (IOException E3) {
                System.out.println(E3.getMessage());
            }

            Map<String, String> properties = jedis.hgetAll("Employe:" + Integer.parseInt(ID1));
            for (Map.Entry<String, String> entry : properties.entrySet()) {
                System.out.println("Name:" + jedis.hget("Employee:" + Integer.parseInt(ID1), "Name"));
                System.out.println("Jobtitle:" + jedis.hget("Employee:" + Integer.parseInt(ID1), "Jobtitle"));
                System.out
                        .println("Department:" + jedis.hget("Employee:" + Integer.parseInt(ID1), "Department"));
            }
            break;

        case "2":
            System.out.print("Get details using Department");
            InputStreamReader IORName1 = new InputStreamReader(System.in);
            BufferedReader BIORName1 = new BufferedReader(IORName1);

            String ID2 = null;
            try {
                ID2 = BIORName1.readLine();
            } catch (IOException E3) {
                System.out.println(E3.getMessage());
            }
            for (int i = 0; i < 100; i++) {
                Map<String, String> properties3 = jedis.hgetAll("Employe:" + i);
                for (Map.Entry<String, String> entry : properties3.entrySet()) {
                    String value = entry.getValue();
                    if (entry.getValue().equals(ID2)) {
                        System.out.println("Name:" + jedis.hget("Employee:" + i, "Name"));
                        System.out.println("Jobtitle:" + jedis.hget("Employee:" + i, "Jobtitle"));
                        System.out.println("Department:" + jedis.hget("Employee:" + i, "Department"));
                    }

                }
            }

            //for (Map.Entry<String, String> entry : properties1.entrySet())
            //{
            //System.out.println(entry.getKey() + "---" + entry.getValue());
            // }
            break;

        case "3":
            for (int i = 1; i < 21; i++) {
                Map<String, String> properties3 = jedis.hgetAll("Employe:" + i);
                for (Map.Entry<String, String> entry : properties3.entrySet()) {

                    // System.out.println(jedis.hget("Employee:" + i,"Name"));
                    System.out.println("Name:" + jedis.hget("Employee:" + i, "Name"));
                    System.out.println("Jobtitle:" + jedis.hget("Employee:" + i, "Jobtitle"));
                    System.out.println("Department:" + jedis.hget("Employee:" + i, "Department"));

                }
            }
            break;
        }

        break;

    // mongo db code goes here 

    case "3":
        MongoClient mongo = new MongoClient(
                new MongoClientURI("mongodb://root2:12345@ds055564.mongolab.com:55564/heroku_766dnj8c"));
        DB db;
        db = mongo.getDB("heroku_766dnj8c");
        // storing values in the database 
        //  for(int i=0;i<100;i++)
        // {
        //     BasicDBObject document = new BasicDBObject();
        //    document.put("_id", i+1);
        //    document.put("Name", Dataarray[i][0]);
        //    document.put("Jobtitle", Dataarray[i][1]);    
        //    document.put("Department", Dataarray[i][2]);    
        //    db.getCollection("EmployeeRaw").insert(document);

        // }
        System.out.println("Search by 1.primary key,2.Name 3.display first 20");
        InputStreamReader objkey6 = new InputStreamReader(System.in);
        BufferedReader objbufkey6 = new BufferedReader(objkey6);
        String interimChoice = null;
        try {
            interimChoice = objbufkey6.readLine();
        } catch (IOException E) {
            System.out.println(E.getMessage());
        }
        switch (interimChoice) {
        case "1":
            System.out.println("Enter the Primary Key");
            InputStreamReader IORPkey = new InputStreamReader(System.in);
            BufferedReader BIORPkey = new BufferedReader(IORPkey);
            int Pkey = 0;
            try {
                Pkey = Integer.parseInt(BIORPkey.readLine());
            } catch (IOException E) {
                System.out.println(E.getMessage());
            }
            BasicDBObject inQuery = new BasicDBObject();
            inQuery.put("_id", Pkey);
            DBCursor cursor = db.getCollection("EmployeeRaw").find(inQuery);
            while (cursor.hasNext()) {
                // System.out.println(cursor.next());
                System.out.println(cursor.next());
            }
            break;
        case "2":
            System.out.println("Enter the Name to Search");
            InputStreamReader objName = new InputStreamReader(System.in);
            BufferedReader objbufName = new BufferedReader(objName);
            String Name = null;
            try {
                Name = objbufName.readLine();
            } catch (IOException E) {
                System.out.println(E.getMessage());
            }
            BasicDBObject inQuery1 = new BasicDBObject();
            inQuery1.put("Name", Name);
            DBCursor cursor1 = db.getCollection("EmployeeRaw").find(inQuery1);
            while (cursor1.hasNext()) {
                // System.out.println(cursor.next());
                System.out.println(cursor1.next());
            }
            break;

        case "3":
            for (int i = 1; i < 21; i++) {
                BasicDBObject inQuerya = new BasicDBObject();
                inQuerya.put("_id", i);
                DBCursor cursora = db.getCollection("EmployeeRaw").find(inQuerya);
                while (cursora.hasNext()) {
                    // System.out.println(cursor.next());
                    System.out.println(cursora.next());
                }
            }
            break;
        }
        break;

    }

}