Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to write color text in text file  RSS feed

 
basanta dwibedy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

During my work i have face a problem .

I want to write Color ful text in a normal test file using java api.

If any body know the code or idia please help me regrad this matter




Basanta
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. Plain text is just that. There is no formatting in a plain text file that lets you specify color/font/size. However, if you are displaying the text in a Bash shell or have configured your windows command console correctly, you could use ANSI Escape Codes to format the text.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How will you display the files? It's not too hard to write HTML which Swing or a browser can render, or RTF which most any word processor can read and edit. As you add formatting the file becomes less "plain text" and more some kind of markup language.
 
basanta dwibedy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,


i want that file in .csv format. through only java api not any thirdparty api.


Because that report has already jenerated and i want to add company name in Different color and size.



So if we have any idea please share with me


 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plain text is... plain. It has no color or style information in it. Sorry.
 
jv patel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not agree with you as we can change font size of text file.
In window 7, we can change font size of text file by using format option of menu.

is there any API to handle font size of text file?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jv patel wrote:I can not agree with you as we can change font size of text file.

No, you can't.

You can change the font or style that a program uses to display the text file to you, but you cannot store style information in the text file itself. Otherwise, it's not a text file, it's something else. Formats like RTF, for example, store style info. But they are not plain text files.

In window 7, we can change font size of text file by using format option of menu.

Again, that is only changing how the text is shown to you on the screen. it has nothing to do with the file itself.

is there any API to handle font size of text file?

No.

Unless, of course, you want to store the information in a format other than plain text.
 
manoochehr karimi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found a way , go  to word pad ,write a word like horse , then you see three A on top of word pad , hover your mouse pointer over the bottom A , it says text color ,  there is a small downward black triangle next to the left of that A, left click on it,it shows a lot of different square colors , click for example on red square then whatever you type after that ,will be typed in red, and if you want to go back to black ,click on black square of those colors , it will type in black...but the problem is this : if you copy that colored text and paste it to another website ,it will be pasted only in black ,but if you paste it on another blank word pad of your computer ,it will be pasted in color...i don't know is this what you want.....of course if you copy any colored text anywhere online , when you paste it ,it is in black....i have windows7 and dell computer and google chrome browser
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manoochehr karimi wrote:i found a way , go  to word pad


By default, WordPad creates a Rich Text Format (RTF) file, so one is able to decorate the text with all manner of effects.  If you attempt to save the WordPad document as a Plain Text Document, which is the subject of this thread, you will get a warning that all text formatting will be removed.
 
manoochehr karimi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess,.... thanks ,btw i made a mistake ,i wrote "there is a small downward black triangle next to the LEFT of that A" , ishould have written RIGHT of that A...sorry
 
Campbell Ritchie
Sheriff
Posts: 53742
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you are still not using text files.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!