Solved

Space assigning or printing error

Posted on 2008-10-28
3
240 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
  • 2
3 Comments
 
LVL 59

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 59

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 71
How can I do a Massively massive community reviewing-and-grading site? 7 69
Unable to start eclipse ? 17 132
oracle 11g 23 49
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now