How can I display a color in java with a certain color,
Please help with an example.
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, ...
No, I just want to display it in the output,
I want the "red color" to be in red.
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.
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.
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
You could display it in a swing.JLabel