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:org.eclipse.ecf.internal.provider.phpbb.Thread.java

public ID postReply(IThreadMessage message) throws IllegalWriteException, BBException {
    if ((mode & READ_ONLY) == READ_ONLY) {
        throw new IllegalWriteException(E_READ_ONLY);
    }//from  w  w  w  .jav a 2s  .c  o  m
    ThreadMessage msg = (ThreadMessage) message;
    // FIXME assert msg.bb == bb;
    assert msg.getThread() == this;
    PostRequest request = new PostRequest(bb.getHttpClient(), bb.getURL(), "posting.php");
    NameValuePair[] params = new NameValuePair[] { new NameValuePair("subject", msg.getName()),
            new NameValuePair("message", msg.getMessage()),
            new NameValuePair("t", String.valueOf(id.getLongValue())), new NameValuePair("mode", "reply"),
            // checkbox : disabled new NameValuePair("disable_smilies",
            // "on"),
            // checkbox : disabled new NameValuePair("disable_bbcode",
            // "on"),
            // checkbox : disabled new NameValuePair("notify", "on"),
            new NameValuePair("post", "Submit") };
    request.addParameters(params);
    String resp = null;
    try {
        request.execute();
        resp = request.getResponseBodyAsString();
        String info = ((PHPBBParser) bb.getParser()).parseInformationMessage(resp);
        Matcher m = Pattern.compile("<a href=\"viewtopic.php\\?p=([0-9]+)(?:.*?)\">").matcher(info);
        if (m.find()) {
            synchronized (this) {
                try {
                    lastReadMessageId = (ThreadMessageID) new ThreadMessageFactory()
                            .createBBObjectId(bb.getNamespace(), bb.getURL(), m.group(1));
                    return lastReadMessageId;
                } catch (NumberFormatException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IDCreateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        } else {
            throw new BBException("The message was not posted.");
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:com.drevelopment.couponcodes.bukkit.coupon.BukkitCouponHandler.java

@Override
public HashMap<Integer, Integer> itemStringToHash(String args, CommandSender sender) {
    HashMap<Integer, Integer> ids = new HashMap<Integer, Integer>();
    String[] sp = args.split(",");
    try {//  ww w.  j  a va2  s  .c  o m
        for (int i = 0; i < sp.length; i++) {
            int a = 0;
            if (StringUtils.isNumeric(sp[i].split(":")[0])) {
                a = Integer.parseInt(sp[i].split(":")[0]);
            } else {
                if (Material.matchMaterial(sp[i].split(":")[0]) != null) {
                    a = Material.matchMaterial(sp[i].split(":")[0]).getId();
                } else {
                    a = 1;
                }
            }
            int b = Integer.parseInt(sp[i].split(":")[1]);
            ids.put(a, b);
        }
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return ids;
}

From source file:jade.core.messaging.FileMessageStorage.java

private void incrementCounter(File f) throws IOException {
    BufferedReader in = new BufferedReader(new FileReader(f));
    File tmp = File.createTempFile("JADE", ".tmp");
    String s = in.readLine();/*from w  w  w .j a  v a2s.  c om*/
    try {
        long counter = Long.parseLong(s);
        BufferedWriter out = new BufferedWriter(new FileWriter(tmp));
        try {
            counter++;
            s = Long.toString(counter);
            out.write(s, 0, s.length());
            out.newLine();

            s = in.readLine();
            while (s != null) {
                out.write(s, 0, s.length());
                out.newLine();
                s = in.readLine();
            }
        } finally {
            out.close();
        }
    } catch (NumberFormatException nfe) {
        nfe.printStackTrace();
    } finally {
        in.close();
    }

    f.delete();
    tmp.renameTo(f);

}

From source file:jp.g_aster.social.action.StampAction.java

/**
 * ?????/*www  . jav  a  2 s  . c o  m*/
 * @return
 */
@PreRenderMethod("getMemberFiles")
public ActionResult showDetail() {

    if (!this.isLogin()) {
        actionContext.getFlashMap().put("error",
                "??????????????");
        return new Redirect("/");
    }

    try {
        log.debug("authenticationKey is " + authKey);
        this.stampDto = stampService.getStamp(authKey);
        if (stampDto.getFileId() == MemberImageFile.FILEID_NOIMAGE) {
            stampDto.setMemberFileUrl("/img/noimage.png");
        }
    } catch (NumberFormatException e) {
        e.printStackTrace();
        actionContext.getFlashMap().put("error",
                "?????????????????");
        new Forward("error.jsp");
    } catch (DataNotFoundException e) {
        e.printStackTrace();
        actionContext.getFlashMap().put("error",
                "?????????????????");
        new Forward("error.jsp");
    }

    return new Forward("stampDetail.jsp");
}

From source file:com.wenwen.chatuidemo.activity.LoginActivity.java

/**
 * /*from  ww  w . j a v  a2 s  .  co m*/
 * 
 * @param view
 */
public void login(View view) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }
    pd = new ProgressDialog(LoginActivity.this);
    pd.setMessage("...");
    RequestParams params = new RequestParams();
    params.put("username", usernameEditText.getText().toString().trim());
    params.put("password", MD5.md5("ys_" + passwordEditText.getText().toString().trim()).toUpperCase());
    params.put("type", "1");
    HttpClientRequest.post(Urls.LOGIG, params, 3000, new AsyncHttpResponseHandler() {
        @Override
        public void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            pd.show();
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            // TODO Auto-generated method stub
            try {
                String res = new String(arg2);
                DebugLog.i("res", res);
                final JSONObject result = new JSONObject(res);
                switch (Integer.valueOf(result.getString("ret"))) {
                case -1:
                    Toast.makeText(LoginActivity.this, "?,", Toast.LENGTH_SHORT).show();
                    break;
                case 1:
                    DemoApplication.getInstance().setUserUid(result.getString("uid"));
                    DemoApplication.getInstance().setAccout_name(result.getString("uname"));
                    // sdk??
                    loginhandler.sendEmptyMessage(1);
                    break;
                case -2:
                    Toast.makeText(LoginActivity.this, "??", Toast.LENGTH_SHORT).show();
                    break;
                case -3:
                case 0:
                    Toast.makeText(LoginActivity.this, "", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;

                }
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        @Override
        public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
        }

        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            // TODO Auto-generated method stub

        }
    });

}

From source file:org.kalypso.kalypsosimulationmodel.core.wind.ASCWindDataModel.java

private void parse(final InputStream inputStream) {
    BufferedReader br = null;/*from  www .j  a  va2  s  .  co m*/
    try {
        br = new BufferedReader(new InputStreamReader(inputStream));
        final String[] data = new String[6];
        String line;
        // reading header data
        for (int i = 0; i < 6; i++) {
            line = br.readLine();
            final int index = line.indexOf(" "); //$NON-NLS-1$
            final String subString = line.substring(index);
            data[i] = subString.trim();
        }
        N_COLS = Integer.parseInt(data[0]);
        N_ROWS = Integer.parseInt(data[1]);
        xllcorner = NumberUtils.parseDouble(data[2]);
        yllcorner = NumberUtils.parseDouble(data[3]);
        cellSize = NumberUtils.parseDouble(data[4]);
        final double noDataValue = NumberUtils.parseDouble(data[5]);
        double currentValueX;
        double currentValueY;

        m_arrayWinds = new Pair[N_ROWS][N_COLS];

        // final String[] strRow;
        for (int y = N_ROWS - 1; y >= 0; y--) {
            final StringTokenizer lStrTokenizer = new StringTokenizer(br.readLine().trim(), " "); //$NON-NLS-1$
            for (int x = 0; x < N_COLS; x++) {
                final String lStrPairOfValues = lStrTokenizer.nextToken();
                final int lIntSeparatorPos = lStrPairOfValues.indexOf(';');
                currentValueX = NumberUtils.parseDouble(lStrPairOfValues.substring(0, lIntSeparatorPos));
                currentValueY = NumberUtils.parseDouble(lStrPairOfValues.substring(lIntSeparatorPos + 1));
                if (currentValueX != noDataValue && currentValueY != noDataValue) {
                    m_arrayWinds[y][x] = new Pair<>(currentValueX, currentValueY);
                } else {
                    m_arrayWinds[y][x] = new Pair<>(Double.NaN, Double.NaN);
                }

            }
        }
        maxEnvelope = makeMaxEnvelope();
    } catch (final NumberFormatException e) {
        e.printStackTrace();
    } catch (final IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(br);
    }
}

From source file:wsattacker.plugin.dos.dosExtension.requestSender.Http4RequestSenderImpl.java

public String sendRequestHttpClient(RequestObject requestObject) {
    String strUrl = requestObject.getEndpoint();
    String strXml = requestObject.getXmlMessage();
    byte[] compressedXml = requestObject.getCompressedXML();

    StringBuffer result = new StringBuffer();
    try {//from w w  w  . j a  va 2s .c o m
        HttpClient client = new DefaultHttpClient();
        setParamsToClient(client);

        if (useProxy) {
            HttpHost proxy = new HttpHost("sbrproxy1.eur.ad.sag", 3103);
            client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        }

        HttpPost post = new HttpPost(strUrl);
        setHeader(requestObject, post);

        ByteArrayEntity entity;
        if (compressedXml != null) {
            entity = new ByteArrayEntity(compressedXml) {
                @Override
                public void writeTo(OutputStream outstream) throws IOException {
                    super.writeTo(outstream);
                    sendLastByte = System.nanoTime();
                }
            };
        } else {
            entity = new ByteArrayEntity(strXml.getBytes("UTF-8")) {
                @Override
                public void writeTo(OutputStream outstream) throws IOException {
                    super.writeTo(outstream);
                    sendLastByte = System.nanoTime();
                }
            };
        }

        post.setEntity(entity);
        HttpResponse response = client.execute(post);
        receiveFirstByte = System.nanoTime();

        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

        String line = "";
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }
    } catch (NumberFormatException e) {

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

    // if (!result.toString().contains("tema tis rolod muspi meroL")) {
    // System.out.println(result);
    // }

    return result.toString();
}

From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java

/**
 * contact/*  w  w w  . jav  a 2 s  .c om*/
 * 
 * @param view
 */
public void addContact(View view) {
    if (DemoApplication.getInstance().getUserName().equals(nameText.getText().toString())) {
        startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?"));
        return;
    }
    final ProgressDialog pd = new ProgressDialog(AddContactActivity.this);
    pd.setMessage("...");
    RequestParams params = new RequestParams();
    DebugLog.i(TAG, "uid" + DemoApplication.getInstance().getUserUid());
    params.put("fromuid", DemoApplication.getInstance().getUserUid());
    params.put("touid", myUser.getAccount_id());
    params.put("flag", "1");
    HttpClientRequest.post(Urls.FRIENDSSET, params, 3000, new AsyncHttpResponseHandler() {
        @Override
        public void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            pd.show();
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            // TODO Auto-generated method stub
            try {
                String res = new String(arg2);
                DebugLog.i(TAG, "" + res);
                JSONObject result = new JSONObject(res);
                switch (Integer.valueOf(result.getString("ret"))) {
                case 0:
                    Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show();
                    break;
                case 1:
                    Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show();
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("myuser", myUser);
                    Intent data = new Intent();
                    data.putExtras(bundle);
                    setResult(Activity.RESULT_OK, data); // ???
                    finish();
                    break;
                case -2:
                    Toast.makeText(AddContactActivity.this, "??", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;

                }
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        @Override
        public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
            pd.dismiss();
        }

        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:com.wenwen.chatuidemo.activity.PersonFragment.java

private void initData() {
    // TODO Auto-generated method stub
    pd = new ProgressDialog(getActivity());
    pd.setMessage("?...");
    RequestParams params = new RequestParams();
    params.put("uid", DemoApplication.getInstance().getUserUid());
    params.put("flag", "1");
    HttpClientRequest.post(Urls.GETUSERDETAILS, params, 3000, new AsyncHttpResponseHandler() {
        @Override/*from  www .j  a  v  a  2 s.  c  o m*/
        public void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            pd.show();
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            // TODO Auto-generated method stub
            /*
             *  * @ret int 0 ? 1 ? -1 ? -2 ?? -3 
             */
            try {
                String res = new String(arg2);
                DebugLog.i("res", res);
                final JSONObject result = new JSONObject(res);
                switch (Integer.valueOf(result.getString("ret"))) {
                case 1:
                    uname.setText(result.getString("account_name"));
                    break;
                default:
                    break;

                }
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        @Override
        public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
            pd.dismiss();
        }

        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:com.binoy.vibhinna.VibhinnaFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    final Cursor cursor = (Cursor) getListAdapter().getItem(menuInfo.position);
    if (cursor == null) {
        // For some reason the requested item isn't available, do nothing
        return false;
    }/*from w ww .  java2  s.  c o  m*/
    final String vPath = cursor.getString(7);
    iconid = Integer.parseInt(cursor.getString(4));
    final int _id;
    try {
        _id = Integer.parseInt(cursor.getString(0));
    } catch (NumberFormatException e1) {
        e1.printStackTrace();
        return false;
    }
    switch (item.getItemId()) {
    case R.id.edit:
        showEditDialog(this, _id);
        return true;
    case R.id.delete:
        new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.delete_vfs, cursor.getString(1)))
                .setMessage(getString(R.string.confirm_delete))
                .setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        try {
                            VibhinnaUtils.removeDirectory(new File(vPath));
                            VibhinnaFragment.this.getActivity().getContentResolver()
                                    .delete(Uri.parse("content://" + VibhinnaProvider.AUTHORITY + "/"
                                            + VibhinnaProvider.VFS_BASE_PATH + "/" + _id), null, null);
                            restartLoading();
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                    }
                }).setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).create().show();
        return true;
    case R.id.format:
        showFormatDialog(this, _id);
        return true;
    case R.id.resize:
        showResizeDialog(this.getActivity(), vPath);
    default:
        return super.onContextItemSelected(item);
    }
}