Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

how to write color text in text file

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Plain text is... plain. It has no color or style information in it. Sorry.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 74661
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you are still not using text files.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic