5
Contributors
6
Replies
8
Views
4 Years
Discussion Span
Last Post by Ene Uran
Featured Replies
  • bguild has already answered your question. Your writer just writes characters to the output stream. Characters do not have fonts, colors, or anything else, they are just characters. Depending on where your file is displayed, characters in the file may be interpreted as formatting information according to some standard, eg … Read More

0

a color with a certain color? you may want to be a bit more specific. do you mean you want to change the color of a text in a JLabel, do you want to set the background color of a JFrame, ...

0

No, I just want to display it in the output,
ex:System.out.println("red color");
I want the "red color" to be in red.

0

You want to include color information in an OutputStream, but OutputStreams don't naturally contain color information. You need to depend upon wherever your stream is going to make the color happen. Some places that read the content of an OutputStream may be able to recognize certain codes and display colors based on those codes, but there is nothing universal.

A quick search found this for me: http://jansi.fusesource.org/
I think you may find it interesting.

0

Can I change the font in a file that I have created

BufferedWriter writer = new BufferedWriter(new FileWriter("test.txt"));
writer.write(flag+"|"+name+"|"+date);

Can I choose a format and a color for the data that I am writing.

2

bguild has already answered your question.
Your writer just writes characters to the output stream. Characters do not have fonts, colors, or anything else, they are just characters.
Depending on where your file is displayed, characters in the file may be interpreted as formatting information according to some standard, eg RTF or HTML. That depends on on how and where the file is being displayed. There is no problem writing RTF or HTML codes to your file, if that's appropriate

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.