9 Replies - 7962 Views - Last Post: 30 December 2009 - 04:03 AM Rate Topic: -----

#1 red001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-December 09

Changing the font style when writing into a text file

Post icon  Posted 03 December 2009 - 12:56 AM

Hi Everyone

Im working on this project where i have to write into a text file a few text data.
I want to give my data a heading in bold.
How do i do this?
How do i set the properties like font size, style, color for a data written using statements like below
fop.write(head.getBytes());


Is this possible to do?
Please let me know

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Changing the font style when writing into a text file

#2 EdwinNameless  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 120
  • View blog
  • Posts: 710
  • Joined: 15-October 09

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 01:31 AM

View Postred001, on 2 Dec, 2009 - 11:56 PM, said:

Hi Everyone

Im working on this project where i have to write into a text file a few text data.
I want to give my data a heading in bold.
How do i do this?
How do i set the properties like font size, style, color for a data written using statements like below
fop.write(head.getBytes());


Is this possible to do?
Please let me know

Thanks


Depends on what format you're using. Since you "seem" to be using FOP (wild guess since it's based on a variable name), I'm going to assume it's PDF, and that you're writing an XML file that's converted with XSLT. In which case, you'd need to alter the XML (haven't looked at FOP for a while, so not sure what the syntax is).

If not, well, then give us more details...
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2639
  • View blog
  • Posts: 11,148
  • Joined: 20-September 08

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 03:34 AM

Quote

Changing the font style when writing into a text file


Text files don't support styling. You need something that does, like rtf or html
Was This Post Helpful? 0
  • +
  • -

#4 red001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-December 09

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 04:19 AM

Im trying write data into a .txt file. Im not using PDF or XML at any pt.

fop is a variable that i have used. Below is code that describes fop.

File f=new File("textfile1.txt");
f.createNewFile();
FileOutputStream fop=new FileOutputStream("textfile1.txt", true);
fop.write('\t');

Im aware that the text format doesnt support font style,
but im willing to open the file with internet explorer.
Wont this give me a chance to change the font?

Please Help

Thanks.
Was This Post Helpful? 0
  • +
  • -

#5 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2639
  • View blog
  • Posts: 11,148
  • Joined: 20-September 08

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 04:30 AM

Quote

but im willing to open the file with internet explorer.
Wont this give me a chance to change the font?


Not unless you use a file format that supports it, such as html
Was This Post Helpful? 0
  • +
  • -

#6 red001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-December 09

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 04:39 AM

Im just curious...

Then how is it that \t works well
ie when i do
fop.write('\t');
it works as expected.

where as \n doesnt work
And now as you say the font properties also dont change?
Was This Post Helpful? 0
  • +
  • -

#7 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2639
  • View blog
  • Posts: 11,148
  • Joined: 20-September 08

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 04:46 AM

Internet Explorer will probably render certain things. \t is not special formatting - it's part of standard text format. \n won't be recognized as html doesn't recognize it, and IE is primarily designed to render html
Was This Post Helpful? 0
  • +
  • -

#8 red001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-December 09

Re: Changing the font style when writing into a text file

Posted 03 December 2009 - 05:25 AM

oook
Thanks
Was This Post Helpful? 0
  • +
  • -

#9 red001  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-December 09

Re: Changing the font style when writing into a text file

Posted 30 December 2009 - 03:52 AM

Hi Everyone

I am trying to write some data into a .csv file using a java program.

I wish to change the font style, color etc.

Can i do this?
Could you please Help...

Thanks
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2639
  • View blog
  • Posts: 11,148
  • Joined: 20-September 08

Re: Changing the font style when writing into a text file

Posted 30 December 2009 - 04:03 AM

Exactly the same applies to .csv files. They too are text files
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1