Printing invalid data to table as blank, and placing the error messages next to each line

Ok, so the last thread i made (Checking each line of data in a text file and identifying invalid data) recieved some wonderful answers which actually helped me a tonne! However, after implementing a version of an answer i ran into something which i didn’t want to happen – that being, the information which was incorrect/missing in the imported text file, wasn’t being printed to the console whatsoever.

An example output of running the program with the code checking each field is correct using IF/try/catch statements is as follows: Console printed output

I’m using the following IF statements to achieve that:

   if(splitText.length < 5){
   System.out.println("nOne or more columns is entirely missing");

   System.out.println("A title may be missing"); //check to see if Title is Empty, and if it is print the rrror

   System.out.println("An author may be missing"); // Check the same thing for Author

   boolean isValidPrice = true;
        try {
             Double.parseDouble(splitText[2]); //trying the Parse the price to Double, and catching any exceptions then switching Boolean to false if exceptions are met
            } catch (Exception e)
                isValidPrice = false;

   System.out.println("nThe following price is invalid: " + splitText[2] + " a value to two decimal places was expected"); //printing the error message if a specific price is incorrectly formatted, only happens if isValidPrice is FALSE

   if(splitText[4].length() != 10){
   System.out.print("nThe following ISBN is incorrect: " +splitText[4]); // checking of the ISBVN is of the correct length, this should be 10numbers long

However this is just printing the error messages in place of the whole line of data (and, sometimes the error messages don’t even print for a specific one at all) – which isn’t what i wanted to achieve, instead i still wanted the invalid data to still be printed, though invalid data would be blank in the table, and the the invalid messages would appear to the side of each incorrect line as it is read.

Removing the check for splitText’s length < 5, creates IndexOutOfBoundsExceptions as data get’s thrown into incorrect places due to misssing data etc.

Data is to generally be in the following format:

Title - Author - Price -  Publisher - ISBN

An example of invalid data is as follows:

- William Stalling - 25.00 - Prentice Hall - 1304086641
Programming with Perl - - 19.99 - Wiley - 0476887021
A Guide to MySQL -Paul Barry -  - Thomson - 1418834351
Perl and CGI - Elizabeth Castro - 99.50 - - 0201735687
Web Design - Hoel Sklar - 9.99 - Course Tech - 
HTML and JavaScript: David  Gast - 12.00 - Wiley 0471383661
Database and Web - Simon Burns - 12Q - Perasons - 0559000412
Trace of Guilt - Neil Barret - 5.99 - Corgi Books - 055X215001

An example of Valid data:

OOP Programming - Graham Winter - 32.50 - O'Reilly - 0471974555
Windows XP Unwired - Wei-Meng Lee - 24.95 - O'Reilly - 0596005369
CCDA Exam Guide - Anthony Bruno - 49.95 - Cisco Press - 0735700745
Multimedia Comms - Fred Halsall - 53.99 - Addison-Wesley - 0201398184
Guide to Networks - Tamara Dean - 34.50 - Course Tech - 1439055661
802.11 Security - Jon Edney and William Hal - 68.99 - Addison-Wesley - 0321136209
Wireless Hacks - Rob Weeks  - 29.50 - O'Reilly - 0596101442
Large Scale LANs - Kevin Dooley - 39.00 - O'Reilly - 0596001509
Learning Java - William Lane - 12.00 -  Wiley - 0811234561

I’m new to java and don’t really know where to go on from that, so literally any help would be gratefully recieved. Thanks once again.

content-length in HttpURLConnection

I’m trying to send a body in x-www-form-urlencoded to my local Web API. I can make GET without any problems. Here is what I do:

    String urlParameters = "user=User&label=GPU+Temp&file=src%2FDataSource0.txt&backgroundColor=rgb(255%2C255%2C255%2C0)&borderColor=rgb(255%2C255%2C255%2C0)&pointBorderColor=rgb(255%2C255%2C255%2C0)&pointHoverBackgroundColor=rgb(255%2C255%2C255%2C0)&pointHoverBorderColor=rgb(255%2C255%2C255%2C0)&min=0&max=100&stepSize=50";

    byte[] postData = urlParameters.getBytes(Charset.forName("UTF-8"));
    int postDataLength = postData.length;
    String request = "";
    URL url = new URL(request);
    con = (HttpURLConnection) url.openConnection();
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    con.setRequestProperty("charset", "utf-8");
    con.setRequestProperty("Content-Length", Integer.toString(postDataLength)); content-length promised 598 bytes, but received 0

So it means that I’m not sending any data in my POST, how come?

Trying to get a random Number for two String lists

Dear Stackoverflow Community,
I am a 14 year old boy and am trying to solve the following problem:
I am trying to develop an app that helps kids to learn French but I have difficulties getting a random number twice, so that if the user presses the second button he gets the German answer.

package com.example.calebseeling.french;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class FrenchActivity extends AppCompatActivity {
    private Button Next;
    private TextView German;
    private TextView French;
    private Button Answer;

    protected void onCreate(Bundle savedInstanceState) {

        Answer = (Button) findViewById(;
        German = (TextView) findViewById(;
        French = (TextView) findViewById(;
        Next = (Button) findViewById(;

        Next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                String getLetter = Letter.getLetter();
        Answer.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {




And here is the following code for the Strings:

package com.example.calebseeling.french;

import java.util.Random;

 * Created by calebseeling on 30.11.17.

public class Letter {

    public static String[] Letters = {
        "Ca va"

    public static String[] LettersG = {
            "Wie Gehts"


    public static String getLetter() {
        Random randomgenerator = new Random();
        int Random = randomgenerator.nextInt(Letters.length);
        return Letters[Random];

Sorting suggested words by usage from Lucene Dictionary

I’m beginner in Java/Lucene. I’m trying to sort first 20 suggested words by most used words in Lucene dictionary.

This code snippet returns me first 20 words beginning by character “a” from field “tokens”:

AnalyzingSuggester suggester = new AnalyzingSuggester(dir, "sugest", new StandardAnalyzer(CharArraySet.EMPTY_SET)); LuceneDictionary(indexReader, "tokens"));
List<LookupResult> lookupResults = suggester.lookup("a", false, 20);

but it is sorted in alphabetical order. I want to sort this by most used words (or “top ranking terms” as it is named in Luke). I found something about Sort and SortField, but I don’t know how to use it in this suggesting scenario. Is there any easy solution for this task or do I need to write own functionality, where I need to get frequency of particular words?

Connection timed out exception

I am trying to access a url from my java code..the code works fine when tested from local machine but throws a connection timed out exception when deployed on server..tried bypassing proxy as well but to no avail..Also there isn’t any firewall on the server.

Note : The url works fine in browser on server.

Here’s the log snippet: Connection timed out: connect [12/1/17
18:15:03:968 IST] 0000011b SystemErr R at Method)
[12/1/17 18:15:03:968 IST] 0000011b SystemErr R at
[12/1/17 18:15:03:968 IST] 0000011b SystemErr R at
[12/1/17 18:15:03:968 IST] 0000011b SystemErr R at
[12/1/17 18:15:03:968 IST] 0000011b SystemErr R at
[12/1/17 18:15:03:968 IST] 0000011b SystemErr R at [12/1/17
18:15:03:968 IST] 0000011b SystemErr R at [12/1/17
18:15:03:968 IST] 0000011b SystemErr R at

Here’s the code snippet:

System.out.println("new::no connect");
    System.out.println("proxy::: "+System.getProperty("https.proxyHost"));
    System.out.println("proxy port before::: "+System.getProperty("https.proxyPort"));

    System.setProperty("https.proxyHost", "");
    System.setProperty("https.proxyPort", "3128");


    System.out.println("proxy after::: "+System.getProperty("https.proxyHost"));
    System.out.println("proxy port: after:: "+System.getProperty("https.proxyPort"));

    boolean redirect = false;
    String APIKey = "test",senderid= "TESTIN",channel="2";
    String DCS="0",flashsms="0",route = "";
    //Prepare Url
    HttpURLConnection myURLConnection=null;
    URL myURL=null;
    BufferedReader reader=null;
    String mainUrl="";
 //prepare connection
    //Prepare parameter string
    StringBuilder sbPostData= new StringBuilder(mainUrl);
    sbPostData.append("APIKey="+ APIKey);
    text = text.replace(" ", "%20");
    //final string
    mainUrl = sbPostData.toString();
 myURL = new URL(mainUrl);
 myURLConnection = (HttpURLConnection) myURL.openConnection();
 System.out.println("myURL:::" + myURL);
 System.out.println("time:: " + myURLConnection.getConnectTimeout());
 System.out.println("time again:: " + myURLConnection.getConnectTimeout());

Getting an exception on .connect() method.

Merge Queues using Recursive

my problem is I couldn’t solve how to merge 2 Queues using the recursive
when I should call back without using any loops and what’s the base case?

 public static <T> merge(Queue<T> q1, Queue<T>q2){
  LinkedQueue<T> t1 = new LinkedQueue<>();
  LinkedQueue<T> t2 = new LinkedQueue<>();


Core.jar not in Zxing Core folder? – Zxing Barcode Scanner

I am trying to follow through with the instructions given on Stack with regards to embedding the Zxing barcode scanner technology without the user having to download the app from the google play store.

I have read that you must copy the “Core.jar” file from the Core folder from the latest version of Zxing library on GitHub. I have downloaded the latest library from GitHub but there is no sign of the Core.jar file??

Can anyone provide me with instructions on how I can do this?