Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:Main.java

public static void main(final String[] args) throws Exception {
    Random RND = new Random();
    ExecutorService es = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
    List<Future<String>> results = new ArrayList<>(10);
    for (int i = 0; i < 10; i++) {
        results.add(es.submit(new TimeSliceTask(RND.nextInt(10), TimeUnit.SECONDS)));
    }/*from   w  w  w .  ja va2s.  c om*/
    es.shutdown();
    while (!results.isEmpty()) {
        Iterator<Future<String>> i = results.iterator();
        while (i.hasNext()) {
            Future<String> f = i.next();
            if (f.isDone()) {
                System.out.println(f.get());
                i.remove();
            }
        }
    }
}

From source file:de.oth.keycloak.InitKeycloakServer.java

public static void main(String[] args) {
    CheckParams checkParams = CheckParams.create(args, System.out, InitKeycloakServer.class.getName());
    if (checkParams == null) {
        System.exit(1);//from w  w  w . j  a va2s. co  m
    }
    try {
        String server = checkParams.getServer();
        String realm = checkParams.getRealm();
        String user = checkParams.getUser();
        String pwd = checkParams.getPwd();
        String clientStr = checkParams.getClient();
        String secret = checkParams.getSecret();
        String initFileStr = checkParams.getInitFile();
        File initFile = new File(initFileStr);
        if (!initFile.isFile()) {
            URL url = InitKeycloakServer.class.getClassLoader().getResource(initFileStr);
            if (url != null) {
                initFile = new File(url.getFile());
                if (!initFile.isFile()) {
                    log.error("init file does not exist: " + initFile);
                    System.exit(1);
                }
            } else {
                log.error("init file does not exist: " + initFile);
                System.exit(1);
            }
        }
        Keycloak keycloak = (secret == null) ? Keycloak.getInstance(server, realm, user, pwd, clientStr)
                : Keycloak.getInstance(server, realm, user, pwd, clientStr, secret);

        ObjectMapper mapper = new ObjectMapper();
        RealmsConfig realmsConfig = mapper.readValue(initFile, RealmsConfig.class);

        if (realmsConfig != null) {
            List<RealmConfig> realmList = realmsConfig.getRealms();
            if (realmList == null || realmList.isEmpty()) {
                log.error("no realms config found 1");
                return;
            }
            for (RealmConfig realmConf : realmList) {
                addRealm(keycloak, realmConf);
            }
        } else {
            log.error("no realms config found 2");
        }
    } catch (Exception e) {
        log.error(e.getClass().getName() + ": " + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:com.ds.test.ClientFormLogin.java

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

    DefaultHttpClient httpclient = new DefaultHttpClient();
    try {/* ww  w. j ava2  s  .c om*/
        HttpGet httpget = new HttpGet("http://www.iteye.com/login");

        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        System.out.println("Login form get: " + response.getStatusLine());

        System.out.println("cookies:");
        List<Cookie> cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
            System.out.println("None");
        } else {
            for (int i = 0; i < cookies.size(); i++) {
                System.out.println(cookies.get(i).toString());
            }
        }

        /* HeaderIterator hi = response.headerIterator();
         while(hi.hasNext()){
            System.out.println(hi.next());
         }
                 
         EntityUtils.consume(entity);
         */

        String token = parseHtml(EntityUtils.toString(entity));

        httpget.releaseConnection();

        System.out.println("********************************************************");

        HttpPost httpost = new HttpPost("http://www.iteye.com/login");

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("name", ""));
        nvps.add(new BasicNameValuePair("password", ""));
        nvps.add(new BasicNameValuePair("authenticity_token", token));

        httpost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

        response = httpclient.execute(httpost);
        entity = response.getEntity();

        System.out.println("Login form get: " + response.getStatusLine());
        EntityUtils.consume(entity);

        System.out.println("Post logon cookies:");
        cookies = httpclient.getCookieStore().getCookies();
        if (cookies.isEmpty()) {
            System.out.println("None");
        } else {
            for (int i = 0; i < cookies.size(); i++) {
                System.out.println(cookies.get(i).toString());
            }
        }

        System.out.println("********************************************************");

        HttpGet httpget2 = new HttpGet("http://www.iteye.com/login");

        HttpResponse response2 = httpclient.execute(httpget2);
        HttpEntity entity2 = response2.getEntity();

        System.out.println("Login form get: " + response2.getStatusLine());

        print(response2);

    } finally {
        // When HttpClient instance is no longer needed,
        // shut down the connection manager to ensure
        // immediate deallocation of all system resources
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:com.atlbike.etl.service.ClientFormLogin.java

/**
 * @param args/*w w w.j ava 2  s .com*/
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    String authenticityToken = "";
    BasicCookieStore cookieStore = new BasicCookieStore();
    CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore)
            .setRedirectStrategy(new LaxRedirectStrategy()).build();
    try {
        HttpGet httpget = new HttpGet("https://atlbike.nationbuilder.com/login");
        CloseableHttpResponse response1 = httpclient.execute(httpget);
        try {
            HttpEntity entity = response1.getEntity();
            System.out.println("Content Length: " + entity.getContentLength());

            System.out.println("Login form get: " + response1.getStatusLine());
            // EntityUtils.consume(entity);
            String content = EntityUtils.toString(entity);
            Document doc = Jsoup.parse(content);
            Elements metaElements = doc.select("META");
            for (Element elem : metaElements) {
                System.out.println(elem);
                if (elem.hasAttr("name") && "csrf-token".equals(elem.attr("name"))) {
                    System.out.println("Value: " + elem.attr("content"));
                    authenticityToken = elem.attr("content");
                }
            }

            System.out.println("Initial set of cookies:");
            List<Cookie> cookies = cookieStore.getCookies();
            if (cookies.isEmpty()) {
                System.out.println("None");
            } else {
                for (int i = 0; i < cookies.size(); i++) {
                    System.out.println("- " + cookies.get(i).toString());
                }
            }
        } finally {
            response1.close();
        }

        HttpUriRequest login = RequestBuilder.post()
                .setUri(new URI("https://atlbike.nationbuilder.com/forms/user_sessions"))
                .addParameter("email_address", "").addParameter("user_session[email]", "email@domain")
                .addParameter("user_session[password]", "magicCookie")
                .addParameter("user_session[remember_me]", "1").addParameter("commit", "Sign in with email")
                .addParameter("authenticity_token", authenticityToken).build();
        CloseableHttpResponse response2 = httpclient.execute(login);
        try {
            HttpEntity entity = response2.getEntity();
            // for (Header h : response2.getAllHeaders()) {
            // System.out.println(h);
            // }
            System.out.println("Content Length: " + entity.getContentLength());

            System.out.println("Login form get: " + response2.getStatusLine());
            EntityUtils.consume(entity);

            System.out.println("Post logon cookies:");
            List<Cookie> cookies = cookieStore.getCookies();
            if (cookies.isEmpty()) {
                System.out.println("None");
            } else {
                for (int i = 0; i < cookies.size(); i++) {
                    System.out.println("- " + cookies.get(i).toString());
                }
            }
        } finally {
            response2.close();
        }

        httpget = new HttpGet(
                // HttpUriRequest file = RequestBuilder
                // .post()
                // .setUri(new URI(
                "https://atlbike.nationbuilder.com/admin/membership_types/14/download");
        // .build();
        // CloseableHttpResponse response3 = httpclient.execute(file);
        CloseableHttpResponse response3 = httpclient.execute(httpget);
        try {
            HttpEntity entity = response3.getEntity();
            System.out.println("Content Length: " + entity.getContentLength());

            System.out.println("File Get: " + response3.getStatusLine());
            saveEntity(entity);
            // EntityUtils.consume(entity);

            System.out.println("Post file get cookies:");
            List<Cookie> cookies = cookieStore.getCookies();
            if (cookies.isEmpty()) {
                System.out.println("None");
            } else {
                for (int i = 0; i < cookies.size(); i++) {
                    System.out.println("- " + cookies.get(i).toString());
                }
            }
        } finally {
            response3.close();
        }

    } finally {
        httpclient.close();
    }
}

From source file:cn.jumper.study.http.ClientFormLogin.java

public static void main(String[] args) throws Exception {
    BasicCookieStore cookieStore = new BasicCookieStore();
    CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();

    HttpHost proxy = new HttpHost("192.168.10.3", 8080, "http");

    RequestConfig config = RequestConfig.custom().setProxy(proxy).build();

    try {//from  w w  w.ja v a2  s . com
        HttpGet httpget = new HttpGet("http://www.ksf-food.com/admin/Login.asp");
        httpget.setConfig(config);
        CloseableHttpResponse response1 = httpclient.execute(httpget);
        try {
            HttpEntity entity = response1.getEntity();

            System.out.println("Login form get: " + response1.getStatusLine());
            EntityUtils.consume(entity);

            System.out.println("Initial set of cookies:");
            List<Cookie> cookies = cookieStore.getCookies();
            if (cookies.isEmpty()) {
                System.out.println("None");
            } else {
                for (int i = 0; i < cookies.size(); i++) {
                    System.out.println("- " + cookies.get(i).toString());
                }
            }
        } finally {
            response1.close();
        }

        String code = "";
        try {
            HttpUriRequest httpgetCode = RequestBuilder.get()
                    .setUri("http://www.ksf-food.com/admin/inc/checkcode.asp").setConfig(config).build();

            /*
             * HttpGet httpgetCode = new HttpGet(
             * "http://www.qufuev.com/admin/inc/checkcode.asp");
             * httpgetCode.setConfig(config);
             */

            System.out.println("Executing request " + httpgetCode.getRequestLine());
            System.out.println("========================================================");
            System.out.println("==httpget header ==");
            for (Header header : httpgetCode.getAllHeaders()) {
                System.out.println(header.getName() + ":" + header.getValue());
            }
            System.out.println("==httpget header ==");

            ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
                public String handleResponse(final HttpResponse response)
                        throws ClientProtocolException, IOException {
                    int status = response.getStatusLine().getStatusCode();
                    if (status >= 200 && status < 300) {
                        HttpEntity entity = response.getEntity();
                        System.out.println("==respons header ==");
                        for (Header header : response.getAllHeaders()) {
                            System.out.println(header.getName() + ":" + header.getValue());
                        }
                        System.out.println("==respons header ==");
                        String fileName = System.currentTimeMillis() + "";
                        DataOutputStream dataOutputStream = new DataOutputStream(
                                new FileOutputStream("d://test//e3//" + fileName + ".jpg"));
                        dataOutputStream.write(EntityUtils.toByteArray(entity));
                        dataOutputStream.close();
                        return ImageTest.getAllOcr("d://test//e3//" + fileName + ".jpg");
                    } else {
                        throw new ClientProtocolException("Unexpected response status: " + status);
                    }
                }

            };
            code = httpclient.execute(httpgetCode, responseHandler);
            System.out.println("ClientFormLogin.main()-CheckCode:" + code);
            System.out.println("----------------------------------------");
        } catch (IOException e) {
            e.printStackTrace();
        }

        HttpUriRequest login = RequestBuilder.post()
                .setUri(new URI("http://www.ksf-food.com/admin/Admin_ChkLogin.asp"))
                .addParameter("UserName", "username").addParameter("Password", "password")
                .addParameter("CheckCode", code).setConfig(config).build();

        System.out.println("========================================================");
        System.out.println("==httpget header ==");
        for (Header header : login.getAllHeaders()) {
            System.out.println(header.getName() + ":" + header.getValue());
        }

        CloseableHttpResponse response2 = httpclient.execute(login);
        try {
            HttpEntity entity = response2.getEntity();

            System.out.println("Login form post: " + response2.getStatusLine());
            // EntityUtils.consume(entity);
            System.out.println("ClientFormLogin.main():\\n" + EntityUtils.toString(entity, "GBK"));

            System.out.println("Post logon cookies:");
            List<Cookie> cookies = cookieStore.getCookies();
            if (cookies.isEmpty()) {
                System.out.println("None");
            } else {
                for (int i = 0; i < cookies.size(); i++) {
                    System.out.println("- " + cookies.get(i).toString());
                }
            }
        } finally {
            response2.close();
        }
    } finally {
        httpclient.close();
    }
}

From source file:com.turn.ttorrent.client.main.TorrentMain.java

/**
 * Torrent creator./*from  w  w  w . j ava2s. c  om*/
 *
 * <p>
 * You can use the {@code main()} function of this class to create
 * torrent files. See usage for details.
 * </p>
 */
public static void main(String[] args) throws Exception {
    // BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%-5p: %m%n")));

    OptionParser parser = new OptionParser();
    OptionSpec<Void> helpOption = parser.accepts("help").forHelp();
    OptionSpec<File> inputOption = parser.accepts("input").withRequiredArg().ofType(File.class).required()
            .describedAs("The input file or directory for the torrent.");
    OptionSpec<File> outputOption = parser.accepts("output").withRequiredArg().ofType(File.class).required()
            .describedAs("The output torrent file.");
    OptionSpec<URI> announceOption = parser.accepts("announce").withRequiredArg().ofType(URI.class).required()
            .describedAs("The announce URL for the torrent.");
    parser.nonOptions().ofType(File.class).describedAs("Files to include in the torrent.");

    OptionSet options = parser.parse(args);
    List<?> otherArgs = options.nonOptionArguments();

    // Display help and exit if requested
    if (options.has(helpOption)) {
        System.out.println("Usage: Torrent [<options>] <torrent-file>");
        parser.printHelpOn(System.err);
        System.exit(0);
    }

    List<File> files = new ArrayList<File>();
    for (Object o : otherArgs)
        files.add((File) o);
    Collections.sort(files);

    TorrentCreator creator = new TorrentCreator(options.valueOf(inputOption));
    if (!files.isEmpty())
        creator.setFiles(files);
    creator.setAnnounceList(options.valuesOf(announceOption));
    Torrent torrent = creator.create();

    File file = options.valueOf(outputOption);
    OutputStream fos = FileUtils.openOutputStream(file);
    try {
        torrent.save(fos);
    } finally {
        IOUtils.closeQuietly(fos);
    }
}

From source file:br.com.asisprojetos.mailreport.Main.java

public static void main(String args[]) {

    logger.debug("Testando debug");

    if (args.length < 2) {
        logger.error("Erro : Numero de parametros errados.");
        System.exit(1);//  ww  w .  j  a v  a2 s  .  c om
    }

    String dataIniProc = String.format("%s 00:00:00", args[0]);
    String dataFimProc = String.format("%s 23:59:59", args[1]);

    logger.debug("Data Inicial: {} , Data Final: {}", dataIniProc, dataFimProc);

    String mes = String.format("%s/%s", args[0].substring(5, 7), args[0].substring(0, 4));

    ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Datasource.xml");

    TBRelatorioEmailDAO tbRelatorioEmailDAO = (TBRelatorioEmailDAO) context.getBean("TBRelatorioEmailDAO");

    List<TBRelatorioEmail> listaRelatorioEmail = tbRelatorioEmailDAO.getAll();

    for (TBRelatorioEmail tbRelatorioEmail : listaRelatorioEmail) {

        logger.debug(" CodContrato: {}, CodProduto: {}", tbRelatorioEmail.getCodContrato(),
                tbRelatorioEmail.getCodProduto());

        List<String> listaEmails = tbRelatorioEmailDAO.getListaEmails(tbRelatorioEmail.getCodContrato());

        if (!listaEmails.isEmpty()) {

            logger.debug("Lista de Emails obtida : [{}] ", listaEmails);

            //List<String> listaCodProduto = Arrays.asList( StringUtils.split(tbRelatorioEmail.getCodProduto(), ';') ) ;
            List<String> listaCodProduto = new ArrayList<String>();
            listaCodProduto.add("1");//Sped Fiscal

            logger.debug("Gerando Relatorio Geral de Consumo por Produto...");

            List<String> fileNames = new ArrayList<String>();
            String fileName;

            BarChartDemo barChartDemo = (BarChartDemo) context.getBean("BarChartDemo");
            //fileName = barChartDemo.generateBarChartGraph(tbRelatorioEmail.getCodContrato());
            //fileNames.add(fileName);
            fileNames = barChartDemo.generateBarChartGraph2(tbRelatorioEmail.getCodContrato());

            String templateFile = null;

            for (String codProduto : listaCodProduto) {

                if (codProduto.equals(Produto.SPED_FISCAL.getCodProduto())) {

                    logger.debug("Produto Codigo : {} ", codProduto);
                    templateFile = "index6.html";

                    //grafico de diagnostico
                    fileName = barChartDemo.generateDiagnosticGraph(tbRelatorioEmail.getCodContrato(),
                            dataIniProc, dataFimProc);
                    fileNames.add(fileName);

                    //grafico de auditoria recorrente
                    fileName = barChartDemo.generateRecurrentGraph(tbRelatorioEmail.getCodContrato(),
                            dataIniProc, dataFimProc);
                    fileNames.add(fileName);

                } else {
                    logger.debug("Produto Codigo : {} no aceito para gerar grafico ", codProduto);
                }

                logger.debug("Enviando Email.............Produto Codigo : {}", codProduto);

                SendEmail sendEmail = (SendEmail) context.getBean("SendEmail");
                sendEmail.enviar(listaEmails.toArray(new String[listaEmails.size()]),
                        "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes,
                        tbRelatorioEmail.getCodContrato());

                //sendEmail.enviar( new String[]{"leandro.prates@asisprojetos.com.br","leandro.prates@gmail.com"}  , 
                //        "Relatrio Mensal de Riscos Fiscais", templateFile, fileNames, mes, tbRelatorioEmail.getCodContrato() );

            }

            //Remover todos os arquivos png gerado para o cliente

            Config config = (Config) context.getBean("Config");

            for (String f : fileNames) {

                try {
                    File file = new File(String.format("%s/%s", config.getOutDirectory(), f));
                    if (file.delete()) {
                        logger.debug("Arquivo: [{}/{}] deletado com sucesso.", config.getOutDirectory(), f);
                    } else {
                        logger.error("Erro ao deletar o arquivo: [{}/{}]", config.getOutDirectory(), f);
                    }

                } catch (Exception ex) {
                    logger.error("Erro ao deletar o arquivo: [{}/{}] . Message {}", config.getOutDirectory(), f,
                            ex);
                }

            }

        }

    }

}

From source file:ar.com.zauber.garfio.Main.java

/**
 * @param args arguments.//w ww . j a va2s  .  c o  m
 * @throws Exception on error 
 */
public static void main(final String[] args) throws Exception {
    if (args.length < 3) {
        System.err.printf("Usage: %s revision username config.properties [dry-run]", Main.class);
        System.exit(1);
    }
    final String revision = args[0];
    final String username = args[1];
    final String config = args[2];
    final boolean isDryRun = args.length >= 4 && "dry-run".equals(args[3]);

    final PropertiesConfiguration configuration = getConfiguration(config, username, revision);
    final GarfioService garfioService = new DefaultGarfioService(getConfigurationDAO(configuration),
            getErrorNotificator());

    final StringWriter writer = new StringWriter();
    IOUtil.copy(System.in, writer);

    if (isDryRun) {
        final List<String> errors = garfioService.dryrun(configuration.getRepositoryName(), username,
                writer.toString());

        for (String error : errors) {
            System.err.println(error);
        }

        System.exit(errors.isEmpty() ? 0 : 1);
    } else {
        garfioService.run(configuration.getRepositoryName(), revision, args[1], writer.toString());
    }
}

From source file:com.muni.fi.pa165.survive.rest.client.SurviveRESTClient.java

public static void main(String[] args) {

    File file = new File("err.txt");
    FileOutputStream fos = null;/*  w  w w  .  jav a 2s.  com*/
    try {
        fos = new FileOutputStream(file);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(SurviveRESTClient.class.getName()).log(Level.SEVERE, null, ex);
    }
    PrintStream ps = new PrintStream(fos);
    System.setErr(ps);

    CommandLineParser parser = new PosixParser();
    Options options = OptionsProvider.getInstance().getOptions();

    try {
        CommandLine line = parser.parse(options, args);
        List<String> validate = CommandLineValidator.validate(line);
        if (!validate.isEmpty()) {
            System.out.println("The following errors occured when parsing the command:");

            for (String string : validate) {
                System.out.println(string);
            }

            System.out.println("");
            printHelp(options);
            System.exit(1);
        }

        if (line.hasOption("h")) {
            printHelp(options);
            System.exit(0);
        }

        CustomRestService crudService;

        String operation = line.getOptionValue("o");

        // weapon mode
        if (line.hasOption("w")) {
            crudService = new WeaponServiceImpl();
            switch (operation) {
            case "C": {
                WeaponDto dto = DtoBuilder.getWeaponDto(line);
                Object byId = crudService.create(dto);
                printEntity(crudService.getResponse(), "Creating a weapon", byId);
                break;
            }
            case "R": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.getById(id);
                printEntity(crudService.getResponse(), "Reading a weapon with id " + id, byId);
                break;
            }
            case "U": {

                WeaponDto dto = DtoBuilder.getWeaponDto(line);
                Object byId = crudService.update(dto);
                printEntity(crudService.getResponse(), "Updating a weapon with id " + line.getOptionValue("i"),
                        byId);

                break;
            }
            case "D": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Response delete = crudService.delete(id);
                printEntity(crudService.getResponse(), "Deleting a weapon with id " + line.getOptionValue("i"),
                        crudService.getResponse().getStatusInfo());
                break;
            }
            case "A":
                List<AbstractDto> all = crudService.getAll();
                printEntities(crudService.getResponse(), "Reading all weapons", all);

                break;
            }
        } else if (line.hasOption("a")) {
            crudService = new AreaServiceImpl();
            switch (operation) {
            case "C": {
                AreaDto dto = DtoBuilder.getAreaDto(line);
                Object byId = crudService.create(dto);
                printEntity(crudService.getResponse(), "Creating an area", byId);
                break;
            }
            case "R": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.getById(id);
                printEntity(crudService.getResponse(), "Reading an area with id " + id, byId);
                break;
            }
            case "U": {
                AreaDto dto = DtoBuilder.getAreaDto(line);
                Object byId = crudService.update(dto);
                printEntity(crudService.getResponse(), "Updating an area with id " + line.getOptionValue("i"),
                        byId);
                break;
            }
            case "D": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.delete(id);
                printEntity(crudService.getResponse(), "Deleting an area with id " + line.getOptionValue("i"),
                        crudService.getResponse().getStatusInfo());
                break;
            }
            case "A":
                List<AbstractDto> all = crudService.getAll();
                printEntities(crudService.getResponse(), "Reading all areas", all);
                break;
            }
        } else {
            printHelp(options);
        }
    } catch (ParseException ex) {
        System.out.println(ex.getMessage());
        printHelp(options);
        System.exit(1);
    } catch (NumberFormatException ex) {
        System.out.println(ex.getMessage());
        printHelp(options);
        System.exit(2);
    } catch (MessageBodyProviderNotFoundException ex) {
        System.out.println("Couldn't connect to the server! Please make sure that the server side is running.");
        System.exit(3);
    } catch (ProcessingException ex) {
        System.out.println("Couldn't connect to the server! Please make sure that the server side is running.");
        System.exit(4);
    } catch (Exception ex) {
        System.out.println(
                "There was an error when connecting to the server. Please make sure that the server side is running.");
    }
}

From source file:EnumSpy.java

public static void main(String... args) {
    try {//from   w ww.  j  a  va2 s.c o  m
        Class<?> c = Class.forName(args[0]);
        if (!c.isEnum()) {
            out.format("%s is not an enum type%n", c);
            return;
        }
        out.format("Class:  %s%n", c);

        Field[] flds = c.getDeclaredFields();
        List<Field> cst = new ArrayList<Field>(); // enum constants
        List<Field> mbr = new ArrayList<Field>(); // member fields
        for (Field f : flds) {
            if (f.isEnumConstant())
                cst.add(f);
            else
                mbr.add(f);
        }
        if (!cst.isEmpty())
            print(cst, "Constant");
        if (!mbr.isEmpty())
            print(mbr, "Field");

        Constructor[] ctors = c.getDeclaredConstructors();
        for (Constructor ctor : ctors) {
            out.format(fmt, "Constructor", ctor.toGenericString(), synthetic(ctor));
        }

        Method[] mths = c.getDeclaredMethods();
        for (Method m : mths) {
            out.format(fmt, "Method", m.toGenericString(), synthetic(m));
        }

        // production code should handle this exception more gracefully
    } catch (ClassNotFoundException x) {
        x.printStackTrace();
    }
}