Example usage for java.lang NumberFormatException printStackTrace

List of usage examples for java.lang NumberFormatException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.circle_technologies.cnn4j.predictive.command.CommandTrain.java

@Override
public String execute(DataAccumulator accumulator, @Nullable CommandLine commandLine) {
    try {// w ww.  j a va  2 s.c  o m
        int epochs = Integer.parseInt(commandLine.getOptionValue("e"));
        getContext().getNetwork().enableWebUi(commandLine.hasOption("w"));
        getContext().getNetwork().train(accumulator.getInputValues(), accumulator.getOutputValues(), epochs);
        return "Training done";

    } catch (NumberFormatException e) {
        Log.info("RNN", "expected epochs param to be an integer: " + e.getMessage());
        e.printStackTrace();

        return "Training failed";
    }

}

From source file:com.rubinefocus.admin.servlet.AdminRegistration.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//from w  ww .  ja v a  2 s  . c  o  m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String name = request.getParameter("name");
    String email = request.getParameter("email");
    String password = request.getParameter("pword");
    String typeString = request.getParameter("type");
    String image = request.getParameter("picName");

    int type = 0;
    try {
        type = Integer.parseInt(typeString);
    } catch (NumberFormatException ee) {
        ee.printStackTrace();
    }

    Admin admin = new Admin();
    admin.setName(name);
    admin.setEmail(email);
    admin.setPassword(password);
    admin.setAdminType(type);
    admin.setImage("assets" + File.separator + "images" + File.separator + "adminPic" + File.separator + image);

    AdminManager am = new AdminManager();
    int id = am.adminRegistration(admin);

    admin.setId(id);

    Gson gson = new Gson();
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(gson.toJson(admin));

}

From source file:eu.vital.maps.server.servlets.KmlGenerator.java

/**
 * grab a parameter from the request query string http://domain.tld?id=[0-9]+
 * /*from  w w w .j  a  v  a 2 s. c om*/
 * @param req
 * @param parameter
 * @return returns a long
 */
private Long getParameterLong(HttpServletRequest req, String parameter) {
    String s = req.getParameter(parameter);
    if (s == null) {
        return null;
    }
    Long id = null;
    try {
        id = Long.parseLong(s);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return id;
}

From source file:com.vportal.portal.events.SessionDestroyAction.java

public void run(HttpSession ses) throws ActionException {
    if (_log.isDebugEnabled()) {
        _log.debug(ses.getId());//www .  jav a2 s  .  c o  m
    }

    MethodKey methodkeyLiveSessions = new MethodKey("com.liferay.portal.util.WebAppPool", "get", String.class,
            String.class);
    Object[] argsLiveSessions = new Object[] { String.valueOf(MainServlet.DEFAULT_COMPANY_ID),
            PropsUtilExt.LIVE_SESSIONS };

    int liveSessions = 0;
    try {
        liveSessions = Integer.parseInt(GetterUtil
                .get((String) PortalClassInvoker.invoke(false, methodkeyLiveSessions, argsLiveSessions), "0"));
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (liveSessions > 0) {

        liveSessions--;

        /*WebAppPool.put(String.valueOf(MainServlet.DEFAULT_COMPANY_ID),
              PropsUtilExt.LIVE_SESSIONS, String.valueOf(liveSessions));*/
        MethodKey method = new MethodKey("com.liferay.portal.util.WebAppPool", "put", String.class,
                String.class, String.class);
        Object[] args = new Object[] { MainServlet.DEFAULT_COMPANY_ID, PropsUtilExt.LIVE_SESSIONS,
                String.valueOf(liveSessions) };
        try {
            PortalClassInvoker.invoke(false, method, args);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }

}

From source file:com.hihframework.core.utils.StringHelpers.java

/**
 * string.//from w  ww. j  a  v  a  2 s .  co  m
 *
 * @param str ?
 * @return 
 */
public static int strToInt(final String str) {
    int i = 0;
    if (str != null && str.length() != 0) {
        try {
            i = Integer.parseInt(str.trim());
        } catch (final NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
    return i;
}

From source file:com.hihframework.core.utils.StringHelpers.java

/**
 * stringDouble.//from   w  w  w. ja va  2 s.co  m
 *
 * @param str ?
 * @return double
 */
public static double strToDouble(final String str) {
    double i = 0;
    if (str != null && str.length() != 0) {
        try {
            i = Double.parseDouble(str.trim());
        } catch (final NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
    return i;
}

From source file:com.fabernovel.alertevoirie.data.CategoryProvider.java

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    JSONArray array = new JSONArray();
    try {//from  w w  w .jav a2 s .  co m
        String categoryId = JsonData.VALUE_NULL;
        switch (uriMatcher.match(uri)) {
        case CATEGORIES_ID:
            categoryId = uri.getLastPathSegment();
            //$FALL-THROUGH$
        case CATEGORIES:
            JSONObject parent = categories.getJSONObject(categoryId);
            if (parent.has(JsonData.PARAM_CATEGORY_CHILDREN)) {
                JSONArray subset = parent.getJSONArray(JsonData.PARAM_CATEGORY_CHILDREN);
                for (int i = 0; i < subset.length(); i++) {
                    JSONObject obj = categories.getJSONObject(subset.getString(i));
                    obj.put(BaseColumns._ID, (long) Integer.valueOf(subset.getString(i)));
                    array.put(obj);
                }
            }
            break;

        case CATEGORY_ID:
            categoryId = uri.getLastPathSegment();
            array.put(categories.getJSONObject(categoryId));
            Log.d(Constants.PROJECT_TAG, "category returned = " + categories.getJSONObject(categoryId));
            break;

        default:
            return null;
        }

    } catch (NumberFormatException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    Cursor c = new JSONCursor(array, projection);
    if (c != null)
        c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}

From source file:org.openmrs.module.DeIdentifiedPatientDataExportModule.web.controller.ConfigureProfileController.java

private void manageSections(HttpServletRequest request, String section) {
    DeIdentifiedExportService d = Context.getService(DeIdentifiedExportService.class);
    String s = request.getParameter(section + "Counter");

    if (s != null) {
        Integer j = Integer.parseInt(s);
        List conceptIds = new ArrayList();
        if (j > 0) {

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

                    Integer conceptId = Integer.parseInt(request.getParameter(section + i + "_span_hid"));
                    conceptIds.add(conceptId);
                } catch (NumberFormatException n) {
                    n.printStackTrace();
                }// www.j  a v  a  2  s.c o  m
            }
        }
        try {
            if (conceptIds.size() > 0)
                d.saveConceptAsSections(conceptIds, section);
            request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "");
        } catch (DAOException e) {
            request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,
                    Context.getMessageSourceService().getMessage("ExportCCD.could.not.save"));
        } catch (APIException e) {
            request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
        } catch (Exception e) {
            request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
        }
    }

}

From source file:ejportal.dao.hibernate.EzbDatenDaoHibernate.java

public List<EzbDaten> findBySearchTO(final EzbDatenSearchTO ezbDatenSearchTO, final Integer maxResults) {
    final Session session = this.getSessionFactory().openSession();
    List searchResult = null;// w w  w  .  jav  a 2s .c  om
    try {
        final Criteria criteria = session.createCriteria(EzbDaten.class);
        criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);

        criteria.setFirstResult(0);
        if (maxResults != null) {
            criteria.setMaxResults(maxResults);
        }

        if (!ezbDatenSearchTO.getEzbId().equals("")) {
            try {
                final long ezbId = Long.parseLong(ezbDatenSearchTO.getEzbId());
                criteria.add(Restrictions.eq("ezbId", ezbId));
            } catch (final NumberFormatException e) {
                // das war wohl nix
                e.printStackTrace();
            }
        }

        if (!ezbDatenSearchTO.getTitel().equals("")) {
            criteria.add(Restrictions.like("titel", "%" + ezbDatenSearchTO.getTitel() + "%").ignoreCase());
        }
        if (!ezbDatenSearchTO.getZdbNummer().equals("")) {
            criteria.add(
                    Restrictions.like("zdbNummer", "%" + ezbDatenSearchTO.getZdbNummer() + "%").ignoreCase());
        }

        searchResult = criteria.list();
    } catch (final Exception e) {
        e.printStackTrace();
    } finally {
        session.close();
    }
    return searchResult;
}

From source file:org.kalypso.model.wspm.ewawi.data.reader.AbstractEwawiReader.java

private void readLine(final String line) throws ParseException {
    try {/*from   w w w  . j  a v a2s . co  m*/
        final String[] tabs = StringUtils.splitPreserveAllTokens(line, '\t'); //$NON-NLS-1$
        readTabs(tabs);
    } catch (final NumberFormatException e) {
        e.printStackTrace();
        throw new ParseException(line, 0);
    }
}