خرید بک لینک

I tried to output to a text file using redirection operators > and >> from a java class but it ignores line feed n from java when the .txt file is opened with the Notepad from windows 10. It's interesting because on the prompt the line feed works just fine and if I use System.out.println("") it works normally in the Notepad.

Class with n line feed:

class n{

    public static void main(String[] args){

        System.out.print("Thisn");
        System.out.print("Shouldn");
        System.out.print("Ben");
        System.out.print("Separated.n");


    }

}

Class using System.out.println(""):

class ln{

    public static void main(String[] args){

        System.out.println("This");
        System.out.println("Should");
        System.out.println("Be");
        System.out.println("Separated.");

    }

}

Output in the prompt:

Prompt

Output in text file from class n (n.txt) opened with Notepad:

ThisShouldBeSeparated.

Output in text file from class ln (ln.txt) opened with Notepad:

This
Should
Be
Separated.

These two above should be equal.

I tested with the class n public but it didn't change the result.

I've searched and found about how to echo a line feed, that's not what I want, I want the redirected text file working like the prompt.

One interesting detail is when I paste the text from n.txt in here (writing a question), in the Microsoft Word, Notepad++ or WordPad (or open the file in the programs cited) it "fixed" the error and was equal the result from class ln.

برچسب: نویسنده: استخدام کار تاريخ: شنبه 1 خرداد 1395 ساعت: 0:43

صفحه بندی