PrintWriter.println - works - but not print?

252 views Asked by At

i have a really suspicious case here, envolving a simple method which is supposed to write into a .txt file.

public void extractCoNLL(int n, String outputFile) throws IOException {

    String msg;
    PrintWriter pr = new PrintWriter(outputFile);
    FileInputStream fConlliN = new FileInputStream(this.txt_CoNLL_in);
    BufferedReader readBufferData = new BufferedReader(new InputStreamReader(fConlliN));

    try {
        while ((msg = readBufferData.readLine()) != null) {
            String aMsg[] = msg.split("\\s+");

            if (!msg.startsWith("#")) {
                //pr.println(msg);

                if (aMsg.length >= n) {
                    pr.print(aMsg[n] + "_");  // DOES NOT WORK
                    pr.println(aMsg[n] + "_");  // WORKS ?????
                    System.out.println(aMsg[4] + aMsg.length);
                } else {
                    pr.println();
                }
            }
        }
        this.txt_CoNLL = out_Extracted_txt_CoNLL;
    } catch (Exception e) {
        System.err.println("Error Exception: " + e.getMessage());
    }
}

Also, why is it not possible for me to add a simple " " -space but i have to be forced to use "_" to seperate the words. Very grateful for your Help. Thank you in advance!

0

There are 0 answers