Example usage for java.lang Error printStackTrace

List of usage examples for java.lang Error printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:Main.java

public static Bitmap decodeSampledBitmapFromFileDescriptor(FileDescriptor fd, long allowedBmpMaxMemorySize) {
    try {//from   w ww  .j a  va 2 s  . c o m
        final Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFileDescriptor(fd, null, options);
        options.inSampleSize = calculateInSampleSize(options, allowedBmpMaxMemorySize);
        options.inJustDecodeBounds = false;
        Bitmap ret = BitmapFactory.decodeFileDescriptor(fd, null, options);

        return ret;
    } catch (Error err) {
        err.printStackTrace();

    }
    return null;
}

From source file:Main.java

public static File downloadFile(String urlstr, File saveFile) {
    try {//from  w w  w .j  a v a2 s . c o m
        URL url = new URL(urlstr);// cause speed low.
        URLConnection con = url.openConnection();
        con.setDoInput(true);
        con.connect();
        InputStream ins = con.getInputStream();
        final int bufsize = 102400;

        byte[] buffer = new byte[bufsize];
        int len = -1;
        FileOutputStream bos = new FileOutputStream(saveFile);
        while ((len = ins.read(buffer)) != -1) {
            bos.write(buffer, 0, len);

        }
        ins.close();
        bos.close();
        return saveFile;
    } catch (Error e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static boolean saveJPEGBitmap(Bitmap aBmp, String aPath) {
    if (aBmp == null || aPath == null) {
        return false;
    }/* w w w  . j  ava 2 s.  c  o m*/

    FileOutputStream fos = null;
    ByteArrayOutputStream baos = null;
    boolean result = false;
    try {
        File file = new File(aPath);
        if (!file.exists()) {
            file.createNewFile();
        }
        fos = new FileOutputStream(file);
        baos = new ByteArrayOutputStream();
        aBmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); //SUPPRESS CHECKSTYLE
        fos.write(baos.toByteArray());
        baos.flush();
        fos.flush();

        result = true;
    } catch (Error e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        result = false;
    } finally {
        try {
            if (baos != null) {
                baos.close();
            }
            if (fos != null) {
                fos.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return result;
}

From source file:com.notes.listen.FsWatchService.java

@Subscribe
@AllowConcurrentEvents//  w w w .ja va2  s .  co m
public void proc(PathEvent event) {
    try {

        Path path = event.getEventTarget();
        String fileName = FilenameUtils.concat("D:\\temp\\", path.toString());
        if (fileName.endsWith(".aspx")) {

            String fullPath = FilenameUtils.getFullPath(fileName);
            String srcName = FilenameUtils.getBaseName(fileName);

        }
    } catch (Error e) {
        e.printStackTrace();
    }

}

From source file:org.fenixedu.bennu.core.filters.CloseTransactionFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    try {//  w ww .  j a  va 2 s. com
        doChain(request, response, chain);
    } catch (Error t) {
        t.printStackTrace();
        InputStream resource = request.getServletContext().getResourceAsStream("/error.html");
        if (resource != null) {
            ServletOutputStream outputStream = response.getOutputStream();
            response.setContentType("text/html");
            IOUtils.copy(resource, outputStream);
            outputStream.flush();
        } else {
            throw t;
        }
    }
}

From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncCopyMoveTask.java

@Override
protected void onPostExecute(Boolean result) {
    super.onPostExecute(result);

    pd.dismiss();//from w w w  .j  av a  2s. c  om
    if (result == true) {
        if (mShouldMove)
            Toast.makeText(mContext, R.string.done_move, Toast.LENGTH_SHORT).show();
        else
            Toast.makeText(mContext, R.string.done_copy, Toast.LENGTH_SHORT).show();
    } else {
        if (mShouldMove)
            Toast.makeText(mContext, R.string.file_could_not_be_written_new_location, Toast.LENGTH_LONG).show();
        else
            Toast.makeText(mContext, R.string.file_could_not_be_written_new_location, Toast.LENGTH_LONG).show();
    }

    try {
        mFragment.refreshListView();
    } catch (Exception e) {
        e.printStackTrace();
    } catch (Error er) {
        er.printStackTrace();
    }

}

From source file:TimeMIDlet.java

public void run() {
    DatagramConnection conn = null;/*from w  w  w  . j av a2s .  c o  m*/
    display.setCurrent(connectForm);

    try {
        String server = serverName.getString();
        String name = "datagram://" + server + ":" + 13;
        conn = (DatagramConnection) Connector.open(name, Connector.READ_WRITE, false);

        Datagram dg = conn.newDatagram(10);
        dg.setData("Hello".getBytes(), 0, 5);
        conn.send(dg);
        Datagram rdg = conn.newDatagram(512);
        conn.receive(rdg);
        messageLabel.setText(new String(rdg.getData(), 0, rdg.getLength()));
        display.setCurrent(displayForm);

    } catch (Exception ex) {
        display.callSerially(new Runnable() {
            public void run() {
                Alert alert = new Alert("Invalid Address",
                        "The supplied address is invalid\n" + "Please correct it and try again.", null,
                        AlertType.ERROR);
                alert.setTimeout(Alert.FOREVER);
                display.setCurrent(alert, addressForm);
            }
        });
        return;
    } catch (Error err) {
        System.out.println(err);
        err.printStackTrace();
    }
}

From source file:org.dbpedia.spotlight.lucene.index.external.SSEKnowledgeBaseBuilder.java

public void addADocument(String uri, String wikilinks) throws IOException, ConfigurationException {
    Document doc = new Document();
    Field uriField = new Field("URI", uri, Field.Store.YES, Field.Index.NOT_ANALYZED);
    doc.add(uriField);//from  w w w.j ava 2  s  .c  o m
    Field kbField = new Field("KB", wikilinks, Field.Store.YES, Field.Index.NOT_ANALYZED);
    doc.add(kbField);
    try {
        writer.addDocument(doc);
    } catch (Error error) {
        error.printStackTrace();
    }
}

From source file:org.radeox.filter.regex.RegexTokenFilter.java

public String filter(String input, final FilterContext context) {
    setUp(context);/*from ww  w  . ja  va2 s. c o m*/

    String result = null;
    int size = pattern.size();
    for (int i = 0; i < size; i++) {
        Pattern p = (Pattern) pattern.get(i);
        try {
            Matcher m = Matcher.create(input, p);
            result = m.substitute(new Substitution() {
                public void handleMatch(StringBuffer buffer, MatchResult result) {
                    RegexTokenFilter.this.handleMatch(buffer, result, context);
                }
            });

            // result = Util.substitute(matcher, p, new
            // ActionSubstitution(s, this, context), result, limit);
        } catch (Exception e) {
            log.warn("<span class=\"error\">Exception</span>: " + this, e);
        } catch (Error err) {
            log.warn("<span class=\"error\">Error</span>: " + this + ": " + err);
            err.printStackTrace();
        }
        input = result;
    }
    return input;
}

From source file:org.tmjee.miniwiki.radeox.filter.regex.RegexReplaceFilter.java

public String filter(String input, FilterContext context) {
    String result = input;//from   w w  w  .j av  a2  s . co  m
    int size = pattern.size();
    Pattern p;
    String s;
    for (int i = 0; i < size; i++) {
        p = (Pattern) pattern.get(i);
        s = (String) substitute.get(i);
        try {
            Matcher matcher = Matcher.create(result, p);
            result = matcher.substitute(s);

            // Util.substitute(matcher, p, new Perl5Substitution(s, interps), result, limit);
        } catch (Exception e) {
            //log.warn("<span class=\"error\">Exception</span>: " + this + ": " + e);
            log.warn("Exception for: " + this + " " + e);
        } catch (Error err) {
            //log.warn("<span class=\"error\">Error</span>: " + this + ": " + err);
            log.warn("Error for: " + this);
            err.printStackTrace();
        }
    }
    return result;
}