Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Space assigning or printing error

Posted on 2008-10-28
3
Medium Priority
?
252 Views
Last Modified: 2012-05-05
Hello,
I have this line of code: closingRootElement =("</"+rootElement.substring(1,rootElement.length())+">");
and when I print it; pw.print(closingRootElement);
pw is; PrintWriter pw = new PrintWriter(new FileWriter(tempFile));

What I get is:</CorrelationEngineParameters >   There is a space between the s and >, i.e., "s >".
I can not figure out from where this space is coming from.
Any thoughts, suggestions?
0
Comment
Question by:chima
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 2000 total points
ID: 22826060
How is it parsing the rootElement string in the first place?

To fix the problem, you could change code to add trim() function; however, think you want to know what caused it.
closingRootElement =("</"+rootElement.substring(1,rootElement.length()).trim()+">");

Open in new window

0
 

Author Closing Comment

by:chima
ID: 31510929
Dame your good!  Had to add a -1 to the parser;
rootElement = (line.trim().substring(line.trim().indexOf('<'), (line.trim().indexOf("xmlns=")-1)));      
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22826784
<<<<<
Grading Comments:
Dame your good! Had to add a -1 to the parser;
rootElement = (line.trim().substring(line.trim().indexOf('<'), (line.trim().indexOf("xmlns=")-1)));
>>>>>

You got it.  Since there is a space before the xmlns attribute in the tag. :)

Glad to help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question