File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem in alignning the text in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in alignning the text in java?" Watch "Problem in alignning the text in java?" New topic
Author

Problem in alignning the text in java?

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 118
Dear All,

I am using log4j to log the user details when a submit is clicked in form page. Name, Email address, company etc all details of the user. However after writing to log file, when I open the log file in notepad, the alignment is not good, but if i open the log file in wordpad, the alignment is good.

Sample code:

String htmlContent = "\t" + serverProperties.getString("mail.subject")+" "+ mailFrom + " \n"+
"-----------------------------------------------------------------------------------------" + "\n" +
"\t" + "Type " + "\t" + "|" + "\t" + "Product Info " + "\t" + "-" + "\t" + rq_type_info + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Product Demo " + "\t" + "-" + "\t" + rq_type_demo + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Product Evaluation" + "\t" + "-" + "\t" + rq_type_eval + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Services Info " + "\t" + "-" + "\t" + rq_type_services + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Newsletter " + "\t" + "-" + "\t" + rq_type_news + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Contact Sales " + "\t" + "-" + "\t" + rq_type_sales + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Login Access " + "\t" + "-" + "\t" + rq_type_login + "\n" +
"\t" + "\t \t \t \t" + "|" + "\t" + "Others " + "\t" + "-" + "\t" + rq_type_others + "\n" +
"\t" + "Name " + "\t" + "|" + "\t" + name + "\n" +
"\t" + "Company " + "\t" + "|" + "\t" + company +"\n" +
"\t" + "Job Title " + "\t" + "|" + "\t" + jobTitle + "\n" +
"\t" + "Division " + "\t" + "|" + "\t" + division +"\n" +
"\t" + "Email Id " + "\t" + "|" + "\t" + mailFrom + "\n" +
"\t" + "Work Phone " + "\t" + "|" + "\t" + workPhone + "\n" +
"\t" + "Country " + "\t" + "|" + "\t" + country +"\n" +
"\t" + "Areas of Interest " + "\t" + "|" + "\t" + productGroup +"\n" +
"\t" + "Additional Information" + "\t \t" + "|" + "\t" + additionalInfo +" \n"+
"-----------------------------------------------------------------------------------------";

I have done so, using '\t' tab space but this is not common in notepad and in wordpad.

Please let me share your ideas to do it in java, so that the alignment looks good in notepad and in wordpad.

REgards,
Prabhu.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Doesn't log4j supply log formatting mechanisms that mean you don't have to add all these white space characters to your log message?

Indeed it does. Have a read of the documentation about PatternLayouts.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Alignment of plain text in text editors depends on the font you're using, tab size, etc.

Why are you calling a variable "htmlContent" when there's no HTML in it? Is this supposed to actually be an email? An HTML email?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in alignning the text in java?
 
Similar Threads
Problem with XML
UNIX line break problem
JTextPane ignoring new lines when text is loaded from servlet
CR[carrige return] in text file for new line
ASCII encoding in WordPad