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:example.TableExample.java

private void insertRow(ChaincodeStub stub, String[] args, boolean update) {

    int fieldID = 0;

    try {//ww w  . j a va  2 s  .  c  o  m
        fieldID = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
        log.error("Illegal field id -" + e.getMessage());
        return;
    }

    TableProto.Column col1 = TableProto.Column.newBuilder().setUint32(fieldID).build();
    TableProto.Column col2 = TableProto.Column.newBuilder().setString(args[1]).build();
    List<TableProto.Column> cols = new ArrayList<TableProto.Column>();
    cols.add(col1);
    cols.add(col2);

    TableProto.Row row = TableProto.Row.newBuilder().addAllColumns(cols).build();
    try {

        boolean success = false;
        if (update) {
            success = stub.replaceRow(tableName, row);
        } else {
            success = stub.insertRow(tableName, row);
        }
        if (success) {
            log.info("Row successfully inserted");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.zhongsou.souyue.activity.SplashActivity.java

private void wrapGalleryNews(String str) {
    GalleryNewsHomeBean item = new GalleryNewsHomeBean();
    Uri uri = Uri.parse(str);/*from w  w  w .ja v  a  2 s.  c  o m*/
    if (uri != null) {
        String srpId = uri.getQueryParameter("srpid");
        String title = uri.getQueryParameter("title");
        String url = uri.getQueryParameter("url");
        String images = uri.getQueryParameter("img");
        String source = uri.getQueryParameter("source");
        String keyword = uri.getQueryParameter("keyword");
        String pubTime = uri.getQueryParameter("newstime");
        try {
            item.setSrpId(srpId);
            item.setTitle(title);
            item.setUrl(url);
            if (!StringUtils.isEmpty(images)) {
                List<String> imgList = new ArrayList<String>();
                String[] imgs = images.split(",");
                for (String img : imgs) {
                    imgList.add(img);
                }
                item.setImage(imgList);
            }
            item.setSource(source);
            item.setKeyword(keyword);
            item.setPubTime(pubTime);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        pushInfo.setGalleryNews(item);
    }
}

From source file:org.fhaes.gui.ShapeFileDialog.java

@SuppressWarnings("unchecked")
private void doProcessing() throws IOException {

    /*/*from  w  w w . j ava 2 s . co  m*/
     * We use the DataUtilities class to create a FeatureType that will describe the data in our shapefile.
     * 
     * See also the createFeatureType method below for another, more flexible approach.
     */
    final SimpleFeatureType TYPE = createFeatureType(selectedYearsModel.getAllElements());

    List<SimpleFeature> features = new ArrayList<SimpleFeature>();

    /*
     * GeometryFactory will be used to create the geometry attribute of each feature (a Point object for the location)
     */
    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);

    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new FileReader(fhm.getFileSiteResult()));

        /* First line of the data file is the header */
        String line = reader.readLine();
        String tokens2[] = line.split("\\,");
        Integer colcount = tokens2.length;
        reader.close();

        ArrayList yearsToInclude = new ArrayList();

        for (int i = 0; i < lstSelectedYears.getModel().getSize(); i++) {
            yearsToInclude.add(lstSelectedYears.getModel().getElementAt(i));
        }

        for (int col = 1; col < colcount; col++) {
            reader = new BufferedReader(new FileReader(fhm.getFileSiteResult()));
            int linecount = -1;
            SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
            String name = "";
            double latitude = 0;
            double longitude = 0;
            Point point;
            Integer year = 0;
            for (line = reader.readLine(); line != null; line = reader.readLine()) {
                linecount++;

                if (line.trim().length() > 0) { // skip blank lines
                    String tokens[] = line.split("\\,");

                    if (linecount == 0) {
                        name = tokens[col].trim();
                    } else if (linecount == 1) {
                        longitude = Double.parseDouble(tokens[col]);
                    } else if (linecount == 2) {
                        latitude = Double.parseDouble(tokens[col]);
                        /* Longitude (= x coord) first ! */
                        point = geometryFactory.createPoint(new Coordinate(longitude, latitude));
                        featureBuilder.add(point);
                        featureBuilder.add(name);
                    } else {
                        year = Integer.parseInt(tokens[0]);
                        if (ArrayUtils.contains(yearsToInclude.toArray(new Integer[yearsToInclude.size()]),
                                year)) {
                            featureBuilder.add(Integer.parseInt(tokens[col].trim()));
                        } else {
                            log.debug("Not storing info for year = " + year);
                        }

                    }
                }
            }
            SimpleFeature feature = featureBuilder.buildFeature(null);
            features.add(feature);
            reader.close();
        }
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /*
     * Get an output file name and create the new shapefile
     */
    File newFile = new File(txtFilename.getText());

    ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("url", newFile.toURI().toURL());
    params.put("create spatial index", Boolean.TRUE);

    ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);

    /*
     * TYPE is used as a template to describe the file contents
     */
    newDataStore.createSchema(TYPE);
    /*
     * Write the features to the shapefile
     */
    Transaction transaction = new DefaultTransaction("create");

    String typeName = newDataStore.getTypeNames()[0];
    SimpleFeatureSource featureSource = newDataStore.getFeatureSource(typeName);
    SimpleFeatureType SHAPE_TYPE = featureSource.getSchema();
    /*
     * The Shapefile format has a couple limitations: - "the_geom" is always first, and used for the geometry attribute name -
     * "the_geom" must be of type Point, MultiPoint, MuiltiLineString, MultiPolygon - Attribute names are limited in length - Not all
     * data types are supported (example Timestamp represented as Date)
     * 
     * Each data store has different limitations so check the resulting SimpleFeatureType.
     */
    System.out.println("SHAPE:" + SHAPE_TYPE);

    if (featureSource instanceof SimpleFeatureStore) {
        SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        /*
         * SimpleFeatureStore has a method to add features from a SimpleFeatureCollection object, so we use the ListFeatureCollection
         * class to wrap our list of features.
         */
        SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features);
        featureStore.setTransaction(transaction);
        try {
            featureStore.addFeatures(collection);
            transaction.commit();
        } catch (Exception problem) {
            problem.printStackTrace();
            transaction.rollback();
        } finally {
            transaction.close();
        }
    } else {
        System.out.println(typeName + " does not support read/write access");

    }

}

From source file:com.krawler.spring.crm.accountModule.crmAccountDAOImpl.java

public void setCustomData(CrmAccount crmAcc, JSONArray cstmData) {
    StringBuffer fields = new StringBuffer("accountid,company");
    StringBuffer qmarks = new StringBuffer("?,?");
    ArrayList params = new ArrayList();
    params.add(crmAcc.getAccountid());//  ww  w. j  a  v a  2s.c  o m
    params.add(crmAcc.getCompany().getCompanyID());
    boolean hasValue = false;
    try {
        for (int i = 0; i < cstmData.length(); i++) {
            JSONObject jobj = cstmData.getJSONObject(i);
            if (jobj.has(Constants.Crm_custom_field)) {
                String fieldname = jobj.getString(Constants.Crm_custom_field);
                String fielddbname = jobj.getString(fieldname);
                String fieldValue = jobj.getString(fielddbname);
                hasValue = true;
                fielddbname = fielddbname.replace("c", "C");
                Integer xtype = Integer.parseInt(jobj.getString("xtype"));
                if (!StringUtil.isNullOrEmpty(fieldValue) && !StringUtil.isNullOrEmpty(fieldValue.trim())
                        && !fieldValue.equalsIgnoreCase(Constants.field_data_undefined)) {
                    fields.append(',').append(fielddbname);
                    qmarks.append(",?");
                    params.add(fieldValue);
                } else {
                    if (xtype == 7 || xtype == 8 || xtype == 4) {
                        fields.append(',').append(fielddbname);
                        qmarks.append(",?");
                        params.add(null);
                    } else {
                        fields.append(',').append(fielddbname);
                        qmarks.append(",?");
                        params.add("");
                    }
                }
            }
        }
    } catch (NumberFormatException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    if (hasValue) {
        StringBuffer sql = new StringBuffer("insert into crmaccountcustomdata (").append(fields)
                .append(")VALUES(").append(qmarks).append(')');
        updateJDBC(sql.toString(), params.toArray());
    }
}

From source file:CourserankConnector.java

private static List<Course> getRatings(HttpClient httpclient, String abbr, List<Course> deptCourses) {
    ////////////////////////////////////////
    //GETS FIRST PAGE OF RESULTS
    try {//  ww w .  ja v  a 2 s .  co m
        boolean next = true;
        int p = 0;
        while (next) {
            next = false;
            //Post a search request for courserank
            HttpPost post = new HttpPost("https://www.courserank.com/stanford/search_results");

            List<NameValuePair> pairs = new ArrayList<NameValuePair>(2);

            //Only filter for current year
            pairs.add(new BasicNameValuePair("filter_term_currentYear", "on"));
            pairs.add(new BasicNameValuePair("page", "" + p));
            pairs.add(new BasicNameValuePair("query", abbr));

            post.setEntity(new UrlEncodedFormEntity(pairs));
            System.out.println("executing request" + post.getRequestLine());
            HttpResponse resp = httpclient.execute(post);
            HttpEntity ent = resp.getEntity();

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

            String rpage = "";
            if (ent != null) {
                System.out.println("Response content length: " + ent.getContentLength());
                InputStream i = ent.getContent();
                BufferedReader br = new BufferedReader(new InputStreamReader(i));
                String line;
                while ((line = br.readLine()) != null) {
                    rpage += line;
                    //System.out.println(line);
                }
                br.close();
                i.close();
            }
            EntityUtils.consume(ent);

            //Check if there is a next page
            next = rpage.contains("pageNavNext");

            ////////////////////////////////////////////////////
            //PARSE FIRST PAGE OF RESULTS

            //int index = rpage.indexOf("div class=\"searchItem");
            String[] classSplit = rpage.split("div class=\"searchItem");
            p++;
            for (int i = 1; i < classSplit.length; i++) {

                //Extract many useful bits of information
                String str = new String(classSplit[i]);

                //ID
                String CID = getToken(str, "course?id=", "\">");

                // CODE 
                String CODE = getToken(str, "class=\"code\">", ":</").trim();

                //TITLE 
                String NAME = getToken(str, "class=\"title\">", "</");

                //DESCRIP
                String DES = getToken(str, "class=\"description\">", "</");

                //TERM
                String TERM = getToken(str, "Terms:", "|");

                //UNITS
                String UNITS = getToken(str, "Units:", "<br/>");

                //WORKLOAD

                String WLOAD = getToken(str, "Workload:", "|");

                //GER
                String GER = getToken(str, "GERs:", "</d").trim();

                //RATING
                //Construct rating based on number of star images
                int searchIndex = 0;
                double rating = 0;
                while (true) {
                    int ratingIndex = str.indexOf("large_Full", searchIndex);
                    if (ratingIndex == -1) {
                        int halfratingIndex = str.indexOf("large_Half", searchIndex);
                        if (halfratingIndex == -1)
                            break;
                        else
                            rating += .5;
                        break;
                    }
                    searchIndex = ratingIndex + 1;
                    rating++;

                }
                String RATING = "" + rating;

                //GRADE
                //Use either official or unofficial grade whichever is present
                String GRADE = getToken(str, "div class=\"unofficialGrade\">", "</");
                if (GRADE.equals("NOT FOUND")) {
                    GRADE = getToken(str, "div class=\"officialGrade\">", "</");
                }

                //REVIEWS
                String REVIEWS = getToken(str, "class=\"ratings\">", " rating");

                //Copy information for each quarter instance of a course in the list of courses.
                for (int j = 0; j < 4; j++) {
                    Course c = new Course();
                    c.code = CODE;
                    if (j == 0) {
                        c.quarter = "Autumn";
                    } else if (j == 1) {
                        c.quarter = "Winter";
                    } else if (j == 2) {
                        c.quarter = "Spring";
                    } else if (j == 3) {
                        c.quarter = "Summer";
                    }

                    //If course is present in department course list from exploreCourses.  Then update info.
                    if (deptCourses.contains(c)) {
                        c = deptCourses.get(deptCourses.indexOf(c));
                        if (c == null)
                            System.out.println("EMERGENCY");
                        c.avgGrade = GRADE;
                        c.rating = rating;
                        c.numReviews = Integer.parseInt(REVIEWS);
                        //c.ID = Integer.parseInt(CID);
                        c.rating = rating;
                        c.numReviews = Integer.parseInt(REVIEWS);
                        /*
                        try {
                           c.numUnits = Integer.parseInt(UNITS);
                        } catch (NumberFormatException e) {
                           System.out.print(UNITS);
                           int in = UNITS.indexOf("-");
                           c.numUnits = Integer.parseInt(UNITS.substring(in+1,in+2));
                        }*/

                        //Parse out workload and just use the average if two numbers are present, otherwise just use number.
                        WLOAD = WLOAD.trim();
                        if (WLOAD.contains("&")) {
                            WLOAD = (WLOAD.substring(WLOAD.indexOf(" "))).trim();
                        }
                        int wload = -1;
                        if (WLOAD.contains("-")) {
                            wload = (Integer.parseInt(WLOAD.split("-")[0]) + Integer.parseInt(
                                    WLOAD.split("-")[1].substring(0, WLOAD.split("-")[1].indexOf(" ")))) / 2;
                        } else if (!WLOAD.contains("NA")) {
                            wload = Integer.parseInt(WLOAD.substring(0, WLOAD.indexOf(" ")));
                        }
                        //System.out.println("Workload: "+wload);
                        c.workload = wload;
                        //System.out.println(GER);
                        c.universityReqs = GER;
                        deptCourses.set(deptCourses.indexOf(c), c);
                    } else {
                        try {
                            String[] nameParts = CODE.split(" ");
                            int num = Integer.parseInt(nameParts[1]);
                            /*if (num > 299) {
                                next = false;
                             }*/
                        } catch (NumberFormatException e) {

                        }
                    }
                }
                /*System.out.println(""+CODE+" : "+NAME + " : "+CID);
                System.out.println("----------------------------------------");
                System.out.println("Term: "+TERM+" Units: "+UNITS+ " Workload: "+WLOAD + " Grade: "+ GRADE);
                System.out.println("Rating: "+RATING+ " Reviews: "+REVIEWS);
                System.out.println("==========================================");
                System.out.println(DES);
                System.out.println("==========================================");*/

            }
            EntityUtils.consume(ent);
        }
        return deptCourses;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {

    }
    return null;

}

From source file:org.fhaes.gui.ShapeFileDialog.java

@SuppressWarnings("unchecked")
private void doProcessingStyle2() throws IOException {

    /*//from   w w w.  jav  a  2s.  c  o  m
     * We use the DataUtilities class to create a FeatureType that will describe the data in our shapefile.
     * 
     * See also the createFeatureType method below for another, more flexible approach.
     */
    final SimpleFeatureType TYPE2 = createStyle2FeatureType();

    List<SimpleFeature> features = new ArrayList<SimpleFeature>();

    /*
     * GeometryFactory will be used to create the geometry attribute of each feature (a Point object for the location)
     */
    GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);

    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new FileReader(fhm.getFileSiteResult()));

        /* First line of the data file is the header */
        String line = reader.readLine();
        String tokens2[] = line.split("\\,");
        Integer colcount = tokens2.length;
        reader.close();

        ArrayList yearsToInclude = new ArrayList();

        for (int i = 0; i < lstSelectedYears.getModel().getSize(); i++) {
            yearsToInclude.add(lstSelectedYears.getModel().getElementAt(i));
        }

        for (int col = 1; col < colcount; col++) {
            reader = new BufferedReader(new FileReader(fhm.getFileSiteResult()));
            int linecount = -1;
            SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE2);
            String name = "";
            double latitude = 0;
            double longitude = 0;
            Point point = null;
            Integer year = 0;
            for (line = reader.readLine(); line != null; line = reader.readLine()) {
                linecount++;

                if (line.trim().length() > 0) { // skip blank lines
                    String tokens[] = line.split("\\,");

                    if (linecount == 0) {
                        name = tokens[col].trim();
                    } else if (linecount == 1) {
                        longitude = Double.parseDouble(tokens[col]);
                    } else if (linecount == 2) {
                        latitude = Double.parseDouble(tokens[col]);
                        /* Longitude (= x coord) first ! */
                        point = geometryFactory.createPoint(new Coordinate(longitude, latitude));
                    } else {
                        year = Integer.parseInt(tokens[0]);
                        if (ArrayUtils.contains(yearsToInclude.toArray(new Integer[yearsToInclude.size()]),
                                year)) {
                            featureBuilder.add(point);
                            featureBuilder.add(name);
                            featureBuilder.add(year);
                            featureBuilder.add(Integer.parseInt(tokens[col].trim()));
                            SimpleFeature feature = featureBuilder.buildFeature(null);
                            features.add(feature);
                            featureBuilder = new SimpleFeatureBuilder(TYPE2);
                        } else {
                            log.debug("Not storing info for year = " + year);
                        }

                    }
                }

            }

            reader.close();
        }
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            reader.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /*
     * Get an output file name and create the new shapefile
     */
    File newFile = getOutputFile();

    ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("url", newFile.toURI().toURL());
    params.put("create spatial index", Boolean.TRUE);

    ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);

    /*
     * TYPE is used as a template to describe the file contents
     */
    newDataStore.createSchema(TYPE2);
    /*
     * Write the features to the shapefile
     */
    Transaction transaction = new DefaultTransaction("create");

    String typeName = newDataStore.getTypeNames()[0];
    SimpleFeatureSource featureSource = newDataStore.getFeatureSource(typeName);
    SimpleFeatureType SHAPE_TYPE = featureSource.getSchema();
    /*
     * The Shapefile format has a couple limitations: - "the_geom" is always first, and used for the geometry attribute name -
     * "the_geom" must be of type Point, MultiPoint, MuiltiLineString, MultiPolygon - Attribute names are limited in length - Not all
     * data types are supported (example Timestamp represented as Date)
     * 
     * Each data store has different limitations so check the resulting SimpleFeatureType.
     */
    System.out.println("SHAPE:" + SHAPE_TYPE);

    if (featureSource instanceof SimpleFeatureStore) {
        SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        /*
         * SimpleFeatureStore has a method to add features from a SimpleFeatureCollection object, so we use the ListFeatureCollection
         * class to wrap our list of features.
         */
        SimpleFeatureCollection collection = new ListFeatureCollection(TYPE2, features);
        featureStore.setTransaction(transaction);
        try {
            featureStore.addFeatures(collection);
            transaction.commit();
        } catch (Exception problem) {
            problem.printStackTrace();
            transaction.rollback();
        } finally {
            transaction.close();
        }
    } else {
        System.out.println(typeName + " does not support read/write access");

    }

}

From source file:org.forumj.web.servlet.get.Tema.java

/**
 * {@inheritDoc}/*w w  w. j  ava2  s  .c  o  m*/
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    long startTime = new Date().getTime();
    StringBuffer buffer = new StringBuffer();
    try {
        HttpSession session = request.getSession();
        cache(response);
        //  ?  ?? ?  ,  
        Integer pageNumber = request.getParameter("page") == null ? 1
                : Integer.valueOf(request.getParameter("page"));
        // id 
        Long threadId = request.getParameter("id") == null ? 1 : Long.valueOf(request.getParameter("id"));
        // ? ?,   
        String replyPostParameter = request.getParameter("reply");
        String end = request.getParameter("end");
        //  ? ??
        String msg = request.getParameter("msg");
        VoiceService voiceService = FJServiceHolder.getVoiceService();
        PostService postService = FJServiceHolder.getPostService();
        SubscribeService subscribeService = FJServiceHolder.getSubscribeService();
        ThreadService treadService = FJServiceHolder.getThreadService();
        IFJThread thread = treadService.readThread(threadId);
        boolean isAnswer = replyPostParameter != null && !"".equals(replyPostParameter.trim());
        LocaleString locale = (LocaleString) session.getAttribute("locale");
        IUser user = (IUser) session.getAttribute("user");
        IgnorService ignorService = FJServiceHolder.getIgnorService();
        List<IIgnor> ignorList = ignorService.readUserIgnor(user.getId());
        //  ??
        Integer count = thread.getPcount();
        Integer couP = (int) (Math.floor((double) count / user.getPt()) + 2);
        // ?   ? ?,    ?
        boolean lastPost = false;
        if (isAnswer || end != null) {
            pageNumber = couP - 1;
            lastPost = true;
        }
        int nfirstpost = (pageNumber - 1) * user.getPt();
        List<IFJPost> posts = postService.readPosts(user, threadId, nfirstpost, user.getPt(), pageNumber,
                lastPost);
        int postsAmount = posts.size();
        //  ?? ?
        session.setAttribute("page", pageNumber);
        session.setAttribute("id", threadId);
        session.setAttribute("where", request.getContextPath() + "?id=" + threadId + "&page=" + pageNumber);
        int countPosts = 0;
        if (msg != null && !"".equals(msg.trim())) {
            try {
                Long msgId = new Long(msg);
                countPosts = postService.getPostsCountInThread(threadId, msgId);
            } catch (NumberFormatException e) {
                e.printStackTrace();
                msg = null;
            }
            pageNumber = (int) (Math.floor(countPosts / user.getPt()) + 1);
        }
        // ? ?
        // ?
        if (!isRobot(request)) {
            // ?
            treadService.setSeen(user, threadId);
        }
        buffer.append("<!doctype html public \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
        buffer.append("<html>");
        buffer.append("<head>");
        buffer.append("<meta http-equiv='content-type' content='text/html; charset=UTF-8'>");
        // 
        buffer.append(loadCSS("/css/style.css"));
        //  (?)
        buffer.append(loadJavaScript("/js/smile_.js"));
        //  ()
        buffer.append(loadJavaScript("/js/jsignor.js"));
        //  (?)
        buffer.append(loadJavaScript("/js/jssubscribe.js"));
        //  (submit ?)
        buffer.append(post_submit(locale.getString("mess128")));
        //  (? )
        buffer.append(loadJavaScript("/js/jstags.js"));
        buffer.append("<link rel='icon' href='/favicon.ico' type='image/x-icon'>");
        buffer.append("<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>");
        buffer.append("<title>");
        buffer.append("  :: " + thread.getHead());
        buffer.append("</title>");
        buffer.append("</head>");
        //   ?
        buffer.append("<body class='mainBodyBG'>");
        // ? 
        buffer.append("<table border='0' style='border-collapse: collapse' width='100%'>");
        //  ?    
        buffer.append(logo(request));
        //   ??
        buffer.append("<tr>");
        buffer.append("<td width='100%'>");
        buffer.append("<table border='0' style='border-collapse: collapse' width='100%'>");
        //  ""
        buffer.append(menu(request, user, locale, false));
        // ?   ?     colspan!
        buffer.append("<tr><td width=100%>");
        buffer.append("<table width=100%>");
        buffer.append("<tr>");
        buffer.append("<td>");
        buffer.append("<table>");
        buffer.append("<tr>");
        buffer.append("<td class='page'>");
        buffer.append("<font class=mnuforum><b>" + locale.getString("mess22") + "&nbsp;</b></font>");
        buffer.append("</td>");
        int i2 = 0;
        for (int i1 = 1; i1 < couP; i1++) {
            i2 = i2 + 1;
            if ((i1 > (pageNumber - 5) && i1 < (pageNumber + 5)) || i2 == 10 || i1 == 1 || i1 == (couP - 1)) {
                if (i2 == 10)
                    i2 = 0;
                if (i1 == pageNumber) {
                    buffer.append("<td class='pagecurrent'>");
                    buffer.append("<span class=mnuforum><b>" + i1 + "</b></span>");
                    buffer.append("</td>");
                } else {
                    buffer.append("<td class='page'>");
                    buffer.append("<a class=mnuforum href='" + FJUrl.VIEW_THREAD + "?page=" + i1 + "&id="
                            + threadId + "'>" + i1 + "</a>");
                    buffer.append("</td>");
                }
            }
        }
        buffer.append("</tr>");
        buffer.append("</table>");

        buffer.append("</td>");

        buffer.append("<td align=right>");
        //  ? :)
        buffer.append("<span class=posthead>" + locale.getString("mess91") + "</span>");
        buffer.append("</td>");
        buffer.append("</tr></table>");
        buffer.append("</td>");
        buffer.append("</tr></table></td></tr>");
        //   ?? ?
        // ?  
        buffer.append("<tr><td height='400' valign='top'>");
        //  
        buffer.append("<table border='0' cellpadding='2' cellspacing='0' width='100%'>");
        // ? - ? 
        if (postsAmount > count) {
            postsAmount = count - (pageNumber - 1) * user.getPt();
        } else {
            postsAmount = user.getPt();
        }
        // 
        //  ?
        for (int postIndex = 0; postIndex < posts.size(); postIndex++) {
            IFJPost post = posts.get(postIndex);
            buffer.append(writePost(post, ignorList, user, pageNumber, locale, thread, voiceService));
        }
        // / 
        buffer.append("</table>");
        // "" 
        buffer.append("</td>");
        buffer.append("</tr>");
        //   ??
        // ?  ?
        buffer.append("<tr>");
        buffer.append("<td width='100%'>");
        buffer.append("<table border='0' style='border-collapse: collapse' width='100%'>");
        buffer.append("<tr>");
        buffer.append("<td colspan='5'>");
        buffer.append("<table>");
        buffer.append("<tr>");
        buffer.append("<td class='page'>");
        buffer.append("<font class=mnuforum><b>" + locale.getString("mess22") + "&nbsp;</b></font>");
        buffer.append("</td>");
        i2 = 0;
        for (int i1 = 1; i1 < couP; i1++) {
            i2 = i2 + 1;
            if ((i1 > (pageNumber - 5) && i1 < (pageNumber + 5)) || i2 == 10 || i1 == 1 || i1 == (couP - 1)) {
                if (i2 == 10)
                    i2 = 0;
                if (i1 == pageNumber) {
                    buffer.append("<td class='pagecurrent'>");
                    buffer.append("<span class=mnuforum><b>" + i1 + "</b></span>");
                    buffer.append("</td>");
                } else {
                    buffer.append("<td class='page'>");
                    buffer.append("<a class=mnuforum href='" + FJUrl.VIEW_THREAD + "?page=" + i1 + "&id="
                            + threadId + "'>" + i1 + "</a>");
                    buffer.append("</td>");
                }
            }
        }
        buffer.append("</tr>");
        buffer.append("</table>");
        buffer.append("</td>");
        buffer.append("</tr>");
        //  ""
        buffer.append(menu(request, user, locale, false));
        buffer.append("</table></td></tr>");
        if (user.isLogined() && !user.isBanned() && !thread.isClosed()) {
            // ?/?   
            //  ??
            String action = "";
            String mess = "";
            if (subscribeService.isUserSubscribed(threadId, user.getId())) {
                //? ?,  ??
                action = FJUrl.DELETE_SUBSCRIBE + "?pg=" + pageNumber;
                mess = locale.getString("mess90");
            } else {
                //?  -   ???
                action = FJUrl.ADD_SUBSCRIBE + "?pg=" + pageNumber;
                mess = locale.getString("mess89");
            }
            buffer.append("<tr>");
            buffer.append("<td align=right>");
            buffer.append("<form id='subs' action='" + action + "' method='post'>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append(fd_button(mess, "subscribe();", "btn_subs", "1"));
            //  ...
            buffer.append("<input type=hidden name='IDT' value='" + threadId + "'>");
            buffer.append(fd_form_add(user));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</form>");
            buffer.append("</td>");
            buffer.append("</tr>");
            String re = "";
            String head = thread.getHead();
            IFJPost replyPost = null;
            // ? /
            if (isAnswer) {
                replyPost = postService.read(Long.valueOf(replyPostParameter));
                head = removeSlashes(replyPost.getHead().getTitle());
            }
            // ? 
            //   ?
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append("<a name='edit'>&nbsp;");
            buffer.append("</a>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append("<form name='post' action='" + FJUrl.ADD_POST + "' method='post'>");
            buffer.append("<table width='100%'>");
            //
            buffer.append("<tr>");
            buffer.append("<td colspan='2' align='CENTER'>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append(locale.getString("mess59") + ":&nbsp;");
            buffer.append("</td>");
            buffer.append("<td>");
            buffer.append(fd_input("NHEAD", re + HtmlChars.convertHtmlSymbols(head), "70", "1"));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("<tr>");
            // 
            buffer.append("<td width='400' align='CENTER'>");
            buffer.append("<p>");
            buffer.append(locale.getString("mess21") + ":");
            buffer.append("</p>");
            buffer.append("</td>");
            //
            buffer.append("<td align='CENTER'>");
            buffer.append("<p>");
            buffer.append(locale.getString("mess12"));
            buffer.append("</p>");
            buffer.append("</td>");
            buffer.append("</tr>");
            //?
            buffer.append("<tr>");
            buffer.append("<td valign='TOP' width='100%' height='100%'>");
            //
            buffer.append(smiles_add(locale.getString("mess11")));
            buffer.append("</td>");
            buffer.append("<td width='500' align='CENTER' valign='top'>");
            //?
            buffer.append(autotags_add());
            // ?
            String textarea = "";
            if (isAnswer) {
                String ans = request.getParameter("ans");
                if (replyPost.getHead().getAuth().equals(user.getId())) {
                    textarea += HtmlChars.convertHtmlSymbols(removeSlashes(replyPost.getBody().getBody()));
                } else if (ans == null) {
                    textarea += "[quote][b]" + HtmlChars.convertHtmlSymbols(
                            removeSlashes(replyPost.getHead().getAuthor().getNick())) + "[/b] ";
                    textarea += locale.getString("mess14") + String.valueOf((char) 13);
                    textarea += HtmlChars.convertHtmlSymbols(removeSlashes(replyPost.getBody().getBody()))
                            + "[/quote]";
                } else {
                    textarea += "[b]" + removeSlashes(replyPost.getHead().getAuthor().getNick()) + "[/b]";
                    textarea += ", ";
                }
            }
            buffer.append("<textarea rows='20' class='mnuforumSm' id='ed1' name='A2' cols='55'>" + textarea
                    + "</textarea>");
            buffer.append("<br>");
            buffer.append("<input type='checkbox' name='no_exit' value='1'>");
            buffer.append(locale.getString("mess123"));
            //
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append(fd_button(locale.getString("mess13"), "post_submit(\"write_edit\");", "B1", "1"));
            } else {
                buffer.append(fd_button(locale.getString("mess13"), "post_submit(\"write_new\");", "B1", "1"));
            }
            buffer.append("</td>");
            buffer.append("<td>");
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append(fd_button(locale.getString("mess63"), "post_submit(\"view_edit\");", "B1", "1"));
            } else {
                buffer.append(fd_button(locale.getString("mess63"), "post_submit(\"view_new\");", "B3", "1"));
            }
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            //? 
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append("<input type=hidden name='IDB' size='20' value='" + replyPostParameter + "'>");
                buffer.append(
                        "<input type=hidden name='IDTbl' size='20' value='" + replyPost.getTablePost() + "'>");
                buffer.append("<input type=hidden name='IDPst' size='20' value='" + replyPost.getId().toString()
                        + "'>");
                buffer.append("<input type=hidden name='IDTblHead' size='20' value='" + replyPost.getTableHead()
                        + "'>");
                buffer.append("<input type=hidden name='IDHead' size='20' value='"
                        + replyPost.getId().toString() + "'>");
            }
            //id 
            buffer.append("<input type=hidden name='IDT' size='20' value='" + threadId + "'>");
            if (thread.isQuest()) {
                buffer.append("<input type=hidden name='ISQUEST' size='20' value='true'>");
            }
            buffer.append(fd_form_add(user));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</form>");
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</td>");
            buffer.append("</tr>");
        }
        //  , ?  .
        buffer.append(footer(request));
        buffer.append("</table>");
        buffer.append("</body>");
        buffer.append("</html>");
    } catch (Throwable e) {
        buffer = new StringBuffer();
        buffer.append(errorOut(e));
        e.printStackTrace();
    }
    Double allTime = (double) ((new Date().getTime() - startTime));
    DecimalFormat format = new DecimalFormat("##0.###");
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter writer = response.getWriter();
    String out = buffer.toString();
    writer.write(out.replace("_", format.format(allTime / 1000)));
}

From source file:ngo.music.soundcloudplayer.controller.SongController.java

public ArrayList<Category> getOfflineAlbums() {
    // TODO Auto-generated method stub
    boolean isAlbumExsited = false;
    ArrayList<Category> cate = new ArrayList<Category>();
    for (Song song : offlineSongs) {
        String album = song.getAlbum();
        for (Category category : cate) {
            if (category.getTitle().equals(album)) {
                try {
                    category.addSong(song);
                } catch (NumberFormatException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }//from  w  ww .j  a v a 2s.c o m
                isAlbumExsited = true;
                break;
            } else {
                isAlbumExsited = false;
            }
        }
        if (!isAlbumExsited) {
            cate.add(new Category(album, song));
            isAlbumExsited = false;
        }

    }
    return cate;
}

From source file:ngo.music.soundcloudplayer.controller.SongController.java

/**
 * Get the artists of offline song//from   w ww .  j a  v  a 2  s.c  o m
 * 
 * @return
 */
public ArrayList<Category> getOfflineArtists() {
    // TODO Auto-generated method stub
    boolean isArtistExsited = false;
    ArrayList<Category> cate = new ArrayList<Category>();
    for (Song song : offlineSongs) {
        String artist = song.getArtist();
        for (Category category : cate) {
            if (category.getTitle().equals(artist)) {
                try {
                    category.addSong(song);
                } catch (NumberFormatException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Autso-generated catch block
                    e.printStackTrace();
                }
                isArtistExsited = true;
                break;
            } else {
                isArtistExsited = false;
            }
        }
        if (!isArtistExsited) {
            cate.add(new Category(artist, song));
            isArtistExsited = false;
        }

    }
    return cate;
}

From source file:corelyzer.data.CRPreferences.java

public boolean readDisplayConfig(final File aFile) {
    // read the file and loadin setups
    try {/*from   ww  w.  j  av a2 s. c  o  m*/
        FileReader fr = new FileReader(aFile);
        BufferedReader br = new BufferedReader(fr);
        String line;

        line = br.readLine();
        this.screenWidth = new Integer(line);

        line = br.readLine();
        this.screenHeight = new Integer(line);

        line = br.readLine();
        this.numberOfRows = new Integer(line);

        line = br.readLine();
        this.numberOfColumns = new Integer(line);

        line = br.readLine();
        this.dpix = new Float(line);

        line = br.readLine();
        this.dpiy = new Float(line);

        line = br.readLine();
        this.borderUp = new Float(line);

        line = br.readLine();
        this.borderDown = new Float(line);

        line = br.readLine();
        this.borderLeft = new Float(line);

        line = br.readLine();
        this.borderRight = new Float(line);

        try {
            line = br.readLine();
            this.column_offset = new Integer(line);

            line = br.readLine();
            this.row_offset = new Integer(line);
        } catch (NumberFormatException e) {
            System.out.println("[CRPreferences] Ignore rest display.conf");
        }

        br.close();
        fr.close();

        return true;
    } catch (Exception e) {
        System.out.println("ERROR Reading previous display settings");
        e.printStackTrace();

        return false;
    }

}