Solved

Space assigning or printing error

Posted on 2008-10-28
3
248 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

752 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