Sagewire Logo

Weird File Access Problem...

6 Message(s) by 3 Author(s) originally posted in netbeans ide java


From: Sean Carrick Date:   Thursday, December 27, 2007
------=_Part_11175_26124073.1198735135098

Content-Disposition: inline

Hey All,

I'm working in NetBeans 6.0, with JDK 6 update 3, on openSuSE 10.2.

I'm writing a command-line switch for viewing the LICENSE file , which is in
my JAR under loe.resources.files.LICENSE. I'm using the following code to
attempt this:

private static void showLicense() {
// Declare a couple of local variable s for file reading and screen
// writing.
FileReader in = null;
PrintStream out = new PrintStream ( System.out );

try {
in = new FileReader ( adminUtils.validatePath(

Main.class .getResource("/loe/resources/files/LICENSE").toString())
);
int c;

while ( (c = in.read()) != -1 ) {
out.write(c);
}
} catch ( IOException ioE ) {
// Display a message to the user that something went wrong.
String msg = "A problem occurred while trying to show the " +
"text\n" +
"of the LICENSE file in /loe/resources/files/\n\n" +
"Cause: " + ioE.getCause() + "\nMessage: " +
ioE.getLocalizedMessage();
String ttl = "I/O Error";
String typ = "error";

adminUtils.showMessage(null, msg, ttl, typ, ioE, "Main.show" +
"License()");
}
} // End of showLicense() method .

The call to adminUtils.validatePath() above refers to the following method,
which I have posted before in a thread dealing with the '%20' escape sequences
in a URL:

public static String validatePath ( String invalidPath ) {
// Declare our return variable.
String validPath = null; // Initialize it to null.

// Declare a loop control variable.
Boolean valid = false; // Initialize this to having an invalid
path .

// Declare a variable to hold the next location to start saving
// the path.
int nextStart = 0;

while ( valid == false ) {
// See if invalidPath contains any escape sequences.
if ( invalidPath.contains("%20") ) {
// Get the location of the start of the escape sequence.
int escLocation = invalidPath.indexOf("%");

if ( escLocation > 0 ) {
// Store the path starting at the location of the last
// escape sequence, up to the location of the current
// escape sequence.
validPath = validPath + invalidPath.substring( 0,
escLocation ) + " ";

// Store the next start location.
nextStart = escLocation + 3;
} else { // There were no more escape sequences.
validPath = validPath + invalidPath.substring
(nextStart);
} // End of inner if()...else block.

// Truncate invalidPath so that invalidPath.contains("%20")
// will eventually be false.
invalidPath = invalidPath.substring(nextStart);
} else { // Since invalidPath doesn't contain any "%20"
escape
// sequences, we can exit the loop.
valid = true;
} // End of outer if()...else loop.
} // End of while() loop.

// Add the last bit of invalidPath to our validPath variable.
validPath = validPath + invalidPath;

// Next, get rid of the string at the front of the path that ends
// with :/.
int colon Loc = validPath.indexOf(":/");

if ( colonLoc > 0 ) {
// Truncate our valid path to the location of the colon plus
one.
validPath = validPath.substring(colonLoc + 1);
} // End if.

*// // Lastly, we need to check for the name of our JAR file, as
that can
// // cause a problem.
// int jar Loc = validPath.indexOf("/Law_Office_Essentials.jar!");
//
// if ( jarLoc > 0 ) {
// // We need to strip our validPath String into to temporary
Strings,
// // the one before the jarLoc and the one after the jarLoc.
Once
// // we have done that, we can recreate our valid string.
// String frontHalf = validPath.substring(0, jarLoc);
// String backHalf = validPath.substring(jarLoc + 27);
//
// validPath = frontHalf + backHalf;
// } // End of JAR removal.*

// Return our validated path string.
return ( validPath );
} // End of validatePath() method.

The commented code that is *bolded/italicized* above is something that I
tried to see if I could get my LICENSE file to print to the screen, but it
did not work.

My problem is this: When I run this code in the IDE it works *exactly* as
expected...reads in each character of the LICENSE file and output s that
character to the terminal window, which is what I want. However, when I run
this project from the CLI, I get the following error (copied from the error
log that I create):

JAVA.io.FileNotFoundException: /home/sean/NetBeansProjects/Law Office
Essentials/dist/Law_Office_Essentials.jar!/loe/resources/files/LICENSE (No
such file or directory)
at JAVA.io.FileInputStream.open(Native Method)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA:106)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA:66)
at JAVA.io.FileReader.<init>(FileReader.JAVA:41)
at loe.Main.showLicense(Main.JAVA:267)
at loe.Main.main(Main.JAVA:121)

Is the "Law_Office_Essentials.jar!" string in the middle normal? I have never
noticed this before and have successfully done this kind of thing with files
before. However, this is the first time I have tried to do this with a file
in my JARchive. If this is normal, how do I open and print the contents of
that file to the screen? Any help here is greatly appreciated.

Cheers,

Sean Carrick
PekinSOFT Systems
PekinSOFT@xxxxxxxxxxx

------=_Part_11175_26124073.1198735135098

Content-Disposition: inline

Hey All,<br><br>I&#39;m working in NetBeans 6.0, with JDK 6 update 3, on openSuSE 10.2.<br><br>I&#39;m writing a command-line switch for viewing the LICENSE file, which is in my JAR under loe.resources.files.LICENSE.&nbsp; I&#39;m using the following code to attempt this:
<br><br><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; private static void showLicense() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare a couple of local variables for file reading and screen
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // writing.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileReader in = null;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PrintStream out = new PrintStream ( System.out );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in = new FileReader ( adminUtils.validatePath
(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main.class.getResource(&quot;/loe/resources/files/LICENSE&quot;).toString()) );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int c;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ( (c = in.read()) != -1 ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write
(c);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch ( IOException ioE ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Display a message to the user that something went wrong.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String msg = &quot;A problem occurred while trying to show the &quot; +</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;text\n&quot; +</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;of the LICENSE file in /loe/resources/files/\n\n&quot; +
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Cause:&nbsp; &quot; + ioE.getCause() + &quot;\nMessage:&nbsp; &quot; +</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ioE.getLocalizedMessage();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String ttl = &quot;I/O Error&quot;;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String typ = &quot;error&quot;;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adminUtils.showMessage(null, msg, ttl, typ, ioE, &quot;
Main.show&quot; +</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;License()&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; } // End of showLicense() method.</span><br><br>The call to
adminUtils.validatePath() above refers to the following method, which I&#39;ve posted before in a thread dealing with the &#39;%20&#39; escape sequences in a URL:<br><br><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; public static String validatePath ( String invalidPath ) {
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare our return variable.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String validPath = null;&nbsp;&nbsp; // Initialize it to null.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare a loop control variable.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Boolean valid = false; // Initialize this to having an invalid path.
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare a variable to hold the next location to start saving
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the path.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int nextStart = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ( valid == false ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // See if invalidPath contains any escape sequences.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( invalidPath.contains(&quot;%20&quot;) ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the location of the start of the escape sequence.
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int escLocation = invalidPath.indexOf(&quot;%&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( escLocation &gt; 0 ) {</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Store the path starting at the location of the last </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // escape sequence, up to the location of the current</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // escape sequence.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath = validPath + invalidPath.substring( 0, </span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; escLocation ) + &quot; &quot;;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Store the next start location.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nextStart = escLocation + 3;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {&nbsp;&nbsp; // There were no more escape sequences.
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath = validPath + invalidPath.substring(nextStart);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End of inner if()...else block.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Truncate invalidPath so that invalidPath.contains(&quot;%20&quot;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // will eventually be false.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invalidPath =
invalidPath.substring(nextStart);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {&nbsp;&nbsp; // Since invalidPath doesn't contain any &quot;%20&quot; escape
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // sequences, we can exit the loop.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; valid = true;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End of outer if()...else loop.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End of while() loop.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add the last bit of invalidPath to our validPath variable.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath = validPath + invalidPath;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Next, get rid of the&nbsp; string at the front of the path that ends</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // with :/.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int colonLoc = validPath.indexOf(&quot;:/&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( colonLoc &gt; 0 ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Truncate our valid path to the location of the colon plus one.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath = validPath.substring
(colonLoc + 1);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End if.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><i><b><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Lastly, we need to check for the name of our JAR file, as that can</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // cause a problem.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int jarLoc = validPath.indexOf
(&quot;/Law_Office_Essentials.jar!&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( jarLoc &gt; 0 ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // We need to strip our validPath String into to temporary Strings,</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the one before the jarLoc and the one after the jarLoc.&nbsp; Once</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // we&#39;ve done that, we can recreate our valid string.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String frontHalf = validPath.substring(0, jarLoc);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String backHalf = validPath.substring
(jarLoc + 27);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath = frontHalf + backHalf;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End of JAR removal.</span></b></i><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Return our validated path string.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ( validPath );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; } // End of validatePath() method.
</span><br><br>The commented code that is <i><b>bolded/italicized</b></i> above is something that I tried to see if I could get my LICENSE file to print to the screen, but it didn&#39;t work.<br><br>My problem is this:&nbsp; When I run this code in the IDE it works
<b>exactly</b> as expected...reads in each character of the LICENSE file and outputs that character to the terminal window, which is what I want.&nbsp; However, when I run this project from the CLI, I get the following error (copied from the error log that I create):
<br><br><span style="font-family: courier new,monospace;">java.io.FileNotFoundException: /home/sean/NetBeansProjects/Law Office Essentials/dist/Law_Office_Essentials.jar!/loe/resources/files/LICENSE (No such file or directory)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; at JAVA.io.FileInputStream.open(Native Method)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp; at JAVA.io.FileInputStream.&lt;init&gt;(FileInputStream.JAVA:106)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; at JAVA.io.FileInputStream.&lt;init&gt;(FileInputStream.JAVA
:66)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; at JAVA.io.FileReader.&lt;init&gt;(FileReader.JAVA:41)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; at loe.Main.showLicense(Main.JAVA:267)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; at loe.Main.main(Main.JAVA
:121)</span><br><br>Is the &quot;Law_Office_Essentials.jar!&quot; string in the middle normal?&nbsp; I&#39;ve never noticed this before and have successfully done this kind of thing with files before.&nbsp; However, this is the first time I&#39;ve tried to do this with a file in my JARchive.&nbsp; If this is normal, how do I open and print the contents of that file to the screen?&nbsp; Any help here is greatly appreciated.
<br><br>Cheers,<br><br>Sean Carrick<br>PekinSOFT Systems<br><a href="mailto:PekinSOFT@xxxxxxxxxxx">PekinSOFT@xxxxxxxxxxx</a><br>

------=_Part_11175_26124073.1198735135098--


From: Karthik Date:   Thursday, December 27, 2007
--Boundary_(ID_I5ELa53kT7sNpu2JXaa1Gg)


- Can you try changing
in = new FileReader ( adminUtils.validatePath (

Main.class.getResource("/loe/resources/files/LICENSE").toString()) );
to
String s = adminUtils.validatePath (
Main.class.getResource("/loe/resources/files/LICENSE").toString() );
System.out.println(s);
in = new FileReader ( s );
and check the values printed for s from within and outside the ide and
see if they are the same?

- Is there a need to call validatePath() in the above call? Shouldn't
in = new FileReader (
Main.class.getResource("/loe/resources/files/LICENSE").toString() );
work just as well?

regards,
wrote in message:
Hey All,
I'm working in NetBeans 6.0, with JDK 6 update 3, on openSuSE 10.2.
I'm writing a command-line switch for viewing the LICENSE file, which
is in my JAR under loe.resources.files.LICENSE. I'm using the
following code to attempt this:
private static void showLicense() {
// Declare a couple of local variables for file reading and
screen
// writing.
FileReader in = null;
PrintStream out = new PrintStream ( System.out );
try {
in = new FileReader ( adminUtils.validatePath (
Main.class.getResource("/loe/resources/files/LICENSE").toString()) );
int c;
while ( (c = in.read()) != -1 ) {
out.write (c);
}
} catch ( IOException ioE ) {
// Display a message to the user that something went wrong.
String msg = "A problem occurred while trying to show the " +
"text\n" +
"of the LICENSE file in
/loe/resources/files/\n\n" +
"Cause: " + ioE.getCause() + "\nMessage: " +
ioE.getLocalizedMessage();
String ttl = "I/O Error";
String typ = "error";
adminUtils.showMessage(null, msg, ttl, typ, ioE, "
Main.show" +
"License()");
}
} // End of showLicense() method.
The call to adminUtils.validatePath() above refers to the following
method, which I have posted before in a thread dealing with the '%20'
escape sequences in a URL:
public static String validatePath ( String invalidPath ) {
// Declare our return variable.
String validPath = null; // Initialize it to null.
// Declare a loop control variable.
Boolean valid = false; // Initialize this to having an
invalid path.
// Declare a variable to hold the next location to start saving
// the path.
int nextStart = 0;
while ( valid == false ) {
// See if invalidPath contains any escape sequences.
if ( invalidPath.contains("%20") ) {
// Get the location of the start of the escape sequence.
int escLocation = invalidPath.indexOf("%");
if ( escLocation > 0 ) {
// Store the path starting at the location of the
last
// escape sequence, up to the location of the current
// escape sequence.
validPath = validPath + invalidPath.substring( 0,
escLocation ) + " ";
// Store the next start location.
nextStart = escLocation + 3;
} else { // There were no more escape sequences.
validPath = validPath +
invalidPath.substring(nextStart);
} // End of inner if()...else block.
// Truncate invalidPath so that
invalidPath.contains("%20")
// will eventually be false.
invalidPath = invalidPath.substring(nextStart);
} else { // Since invalidPath doesn't contain any
"%20" escape
// sequences, we can exit the loop.
valid = true;
} // End of outer if()...else loop.
} // End of while() loop.
// Add the last bit of invalidPath to our validPath variable.
validPath = validPath + invalidPath;
// Next, get rid of the string at the front of the path that
ends
// with :/.
int colonLoc = validPath.indexOf(":/");
if ( colonLoc > 0 ) {
// Truncate our valid path to the location of the colon
plus one.
validPath = validPath.substring (colonLoc + 1);
} // End if.
/*// // Lastly, we need to check for the name of our JAR file,
as that can
// // cause a problem.
// int jarLoc = validPath.indexOf ("/Law_Office_Essentials.jar!");
//
// if ( jarLoc > 0 ) {
// // We need to strip our validPath String into to
temporary Strings,
// // the one before the jarLoc and the one after the
jarLoc. Once
// // we have done that, we can recreate our valid string.
// String frontHalf = validPath.substring(0, jarLoc);
// String backHalf = validPath.substring (jarLoc + 27);
//
// validPath = frontHalf + backHalf;
// } // End of JAR removal.*/
// Return our validated path string.
return ( validPath );
} // End of validatePath() method.
The commented code that is /*bolded/italicized*/ above is something
that I tried to see if I could get my LICENSE file to print to the
screen, but it did not work.
My problem is this: When I run this code in the IDE it works
*exactly* as expected...reads in each character of the LICENSE file
and outputs that character to the terminal window, which is what I
want. However, when I run this project from the CLI, I get the
following error (copied from the error log that I create):
JAVA.io.FileNotFoundException: /home/sean/NetBeansProjects/Law Office
Essentials/dist/Law_Office_Essentials.jar!/loe/resources/files/LICENSE
(No such file or directory)
at JAVA.io.FileInputStream.open(Native Method)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA:106)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA :66)
at JAVA.io.FileReader.<init>(FileReader.JAVA:41)
at loe.Main.showLicense(Main.JAVA:267)
at loe.Main.main(Main.JAVA :121)
Is the "Law_Office_Essentials.jar!" string in the middle normal? I have
never noticed this before and have successfully done this kind of
thing with files before. However, this is the first time I have tried
to do this with a file in my JARchive. If this is normal, how do I
open and print the contents of that file to the screen? Any help here
is greatly appreciated.
Cheers,
Sean Carrick
PekinSOFT Systems
PekinSOFT@xxxxxxxxxxx <mailto:PekinSOFT@xxxxxxxxxxx>



--Boundary_(ID_I5ELa53kT7sNpu2JXaa1Gg)

--Boundary_(ID_I5ELa53kT7sNpu2JXaa1Gg)--


From: Sean Carrick Date:   Friday, December 28, 2007
------=_Part_14276_13521983.1198818251642

Content-Disposition: inline

Karthik,

OK, firstly, my validatePath() method simply removes the `%20' escape
sequences from the string and replaces them with the space that the escape
wrote in message. Every time that I try to do something with a path that
has the escape sequence, instead of the actual space, I get problems.
wrote in message that little method, I do not get an eighth of the
problems I used to get...until this interesting one (at least I try to keep
people's interest, right?). I tried your suggestion and added the suggested
code to my project. Here are the results:

1. Removing the call to validatePath(), display ing the license doesn't
work in either the IDE nor the CLI.
2. Leaving the call to validatePath(), still works in the IDE...still
throws the IOException in the CLI.

Do you've any other ideas? I'm all ears (or, should I say, eyes).
Thanks for your help.

Cheers,

Sean Carrick
PekinSOFT Systems
PekinSOFT@xxxxxxxxxxx

wrote in message:

- Can you try changing
in = new FileReader ( adminUtils.validatePath (
Main.class.getResource("/loe/resources/files/LICENSE").toString())
);
to
String s = adminUtils.validatePath (
Main.class.getResource("/loe/resources/files/LICENSE").toString()
);
System.out.println(s);
in = new FileReader ( s );
and check the values printed for s from within and outside the ide and see
if they are the same?
- Is there a need to call validatePath() in the above call? Shouldn't
in = new FileReader ( Main.class.getResource("/loe/resources/files/LICENSE").toString()
);
work just as well?
regards,
karthik
wrote in message:
Hey All,
I'm working in NetBeans 6.0, with JDK 6 update 3, on openSuSE 10.2.
I'm writing a command-line switch for viewing the LICENSE file, which is
in my JAR under loe.resources.files.LICENSE. I'm using the following code
to attempt this:
private static void showLicense() {
// Declare a couple of local variables for file reading and screen
// writing.
FileReader in = null;
PrintStream out = new PrintStream ( System.out );
try {
in = new FileReader ( adminUtils.validatePath (
Main.class.getResource("/loe/resources/files/LICENSE").toString())
);
int c;
while ( (c = in.read()) != -1 ) {
out.write (c);
}
} catch ( IOException ioE ) {
// Display a message to the user that something went wrong.
String msg = "A problem occurred while trying to show the " +
"text\n" +
"of the LICENSE file in /loe/resources/files/\n\n" +
"Cause: " + ioE.getCause() + "\nMessage: " +
ioE.getLocalizedMessage();
String ttl = "I/O Error";
String typ = "error";
adminUtils.showMessage(null, msg, ttl, typ, ioE, " Main.show"
+
"License()");
}
} // End of showLicense() method.
The call to adminUtils.validatePath() above refers to the following
method, which I have posted before in a thread dealing with the '%20' escape
sequences in a URL:
public static String validatePath ( String invalidPath ) {
// Declare our return variable.
String validPath = null; // Initialize it to null.
// Declare a loop control variable.
Boolean valid = false; // Initialize this to having an invalid
path.
// Declare a variable to hold the next location to start saving
// the path.
int nextStart = 0;
while ( valid == false ) {
// See if invalidPath contains any escape sequences.
if ( invalidPath.contains("%20") ) {
// Get the location of the start of the escape sequence.
int escLocation = invalidPath.indexOf("%");
if ( escLocation > 0 ) {
// Store the path starting at the location of the
last
// escape sequence, up to the location of the current
// escape sequence.
validPath = validPath + invalidPath.substring( 0,
escLocation ) + " ";
// Store the next start location.
nextStart = escLocation + 3;
} else { // There were no more escape sequences.
validPath = validPath + invalidPath.substring
(nextStart);
} // End of inner if()...else block.
// Truncate invalidPath so that invalidPath.contains
("%20")
// will eventually be false.
invalidPath = invalidPath.substring(nextStart);
} else { // Since invalidPath doesn't contain any "%20"
escape
// sequences, we can exit the loop.
valid = true;
} // End of outer if()...else loop.
} // End of while() loop.
// Add the last bit of invalidPath to our validPath variable.
validPath = validPath + invalidPath;
// Next, get rid of the string at the front of the path that
ends
// with :/.
int colonLoc = validPath.indexOf(":/");
if ( colonLoc > 0 ) {
// Truncate our valid path to the location of the colon plus
one.
validPath = validPath.substring (colonLoc + 1);
} // End if.
*// // Lastly, we need to check for the name of our JAR file, as
that can
// // cause a problem.
// int jarLoc = validPath.indexOf ("/Law_Office_Essentials.jar!");
//
// if ( jarLoc > 0 ) {
// // We need to strip our validPath String into to temporary
Strings,
// // the one before the jarLoc and the one after the jarLoc.
Once
// // we have done that, we can recreate our valid string.
// String frontHalf = validPath.substring(0, jarLoc);
// String backHalf = validPath.substring (jarLoc + 27);
//
// validPath = frontHalf + backHalf;
// } // End of JAR removal.*
// Return our validated path string.
return ( validPath );
} // End of validatePath() method.
The commented code that is *bolded/italicized* above is something that I
tried to see if I could get my LICENSE file to print to the screen, but it
did not work.
My problem is this: When I run this code in the IDE it works *exactly* as
expected...reads in each character of the LICENSE file and outputs that
character to the terminal window, which is what I want. However, when I run
this project from the CLI, I get the following error (copied from the error
log that I create):
JAVA.io.FileNotFoundException: /home/sean/NetBeansProjects/Law Office
Essentials/dist/Law_Office_Essentials.jar!/loe/resources/files/LICENSE (No
such file or directory)
at JAVA.io.FileInputStream.open(Native Method)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA:106)
at JAVA.io.FileInputStream.<init>(FileInputStream.JAVA :66)
at JAVA.io.FileReader.<init>(FileReader.JAVA:41)
at loe.Main.showLicense(Main.JAVA:267)
at loe.Main.main(Main.JAVA :121)
Is the "Law_Office_Essentials.jar!" string in the middle normal? I have
never noticed this before and have successfully done this kind of thing with
files before. However, this is the first time I have tried to do this with a
file in my JARchive. If this is normal, how do I open and print the
contents of that file to the screen? Any help here is greatly appreciated.
Cheers,
Sean Carrick
PekinSOFT Systems
PekinSOFT@xxxxxxxxxxx


------=_Part_14276_13521983.1198818251642

Content-Disposition: inline

wrote in messagewrote in message that little method, I don&#39;t get an eighth of the problems I used to get...until this interesting one (at least I try to keep people&#39;s interest, right?).&nbsp; I tried your suggestion and added the suggested code to my project.&nbsp; Here are the results:
<br><br>1.&nbsp; Removing the call to <span style="font-family: courier new,monospace;">validatePath()</span>, displaying the license doesn't work in either the IDE nor the CLI.<br>2.&nbsp; Leaving the call to <span style="font-family: courier new,monospace;">
validatePath()</span>, still works in the IDE...still throws the IOException in the CLI.<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Do you've any other ideas?&nbsp; I&#39;m all ears (or, should I say, eyes).&nbsp; Thanks for your help.<br><br>Cheers,<br><br>Sean Carrick
<br>PekinSOFT Systems<br><a href="mailto:PekinSOFT@xxxxxxxxxxx">PekinSOFT@xxxxxxxxxxx</a><br><br><div class="gmail_quote">On Dec 27, 2007 1:08 PM, Karthik &lt;<a href="mailto:Karthikeyan.Rajeswaran@xxxxxxxxxxx">Karthikeyan.Rajeswaran@xxxxxxxxxxx
wrote in message:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div bgcolor="#ffffff" text="#000000">
<tt>- Can you try changing<div class="Ih2E3d"><br>
&nbsp;&nbsp;&nbsp; in = new FileReader ( adminUtils.validatePath (<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Main.class.getResource(&quot;/loe/resources/files/LICENSE&quot;).toString()) );<br></div>
to<br>
&nbsp;&nbsp;&nbsp; String s = </tt><tt>adminUtils.validatePath (<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Main.class.getResource(&quot;/loe/resources/files/LICENSE&quot;).toString() );<br>
&nbsp;&nbsp;&nbsp; System.out.println(s);<br>
</tt><tt>&nbsp;&nbsp;&nbsp; in = new FileReader ( s );<br>
and check the values printed for s from within and outside the ide and
see if they are the same?<br>
<br>
- Is there a need to call validatePath() in the above call? Shouldn't<br>
&nbsp;&nbsp;&nbsp; </tt><tt><span style="font-family: courier new,monospace;">in =
new FileReader ( </span><span style="font-family: courier new,monospace;">Main.class.getResource(&quot;/loe/resources/files/LICENSE&quot;).toString()
);<br>
work just as well? </span><br>
<br>
regards,<br><font color="#888888">
karthik<br>
<br>
<br>
wrote in message:</tt>
<blockquote type="cite"><tt>Hey All,<br>
<br>
I&#39;m working in NetBeans 6.0, with JDK 6 update 3, on openSuSE 10.2.<br>
<br>
I&#39;m writing a command-line switch for viewing the LICENSE file, which
is in my JAR under loe.resources.files.LICENSE.&nbsp; I&#39;m using the
following code to attempt this:
<br>
<br>
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; private static
void showLicense() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare
a couple of local variables for file reading and screen </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // writing.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileReader in =
null;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PrintStream out =
new PrintStream ( System.out );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in =
new FileReader ( adminUtils.validatePath
(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Main.class.getResource(&quot;/loe/resources/files/LICENSE&quot;).toString()) );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int c;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (
(c = in.read()) != -1 ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
out.write
(c);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (
IOException ioE ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
Display a message to the user that something went wrong.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
msg = &quot;A problem occurred while trying to show the &quot; +</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;text\n&quot; +</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;of the LICENSE file in /loe/resources/files/\n\n&quot; +
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;Cause:&nbsp; &quot; + ioE.getCause() + &quot;\nMessage:&nbsp; &quot; +</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ioE.getLocalizedMessage();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
ttl = &quot;I/O Error&quot;;
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
typ = &quot;error&quot;;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
adminUtils.showMessage(null, msg, ttl, typ, ioE, &quot;
Main.show&quot; +</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;License()&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; } // End of
showLicense() method.</span><br>
<br>
The call to adminUtils.validatePath() above refers to the following
method, which I&#39;ve posted before in a thread dealing with the &#39;%20&#39;
escape sequences in a URL:<br>
<br>
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; public static
String validatePath ( String invalidPath ) {
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare
our return variable.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String
validPath = null;&nbsp;&nbsp; // Initialize it to null.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare
a loop control variable.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Boolean
valid = false; // Initialize this to having an invalid path.
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Declare
a variable to hold the next location to start saving
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the
path.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
nextStart = 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (
valid == false ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // See
if invalidPath contains any escape sequences.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (
invalidPath.contains(&quot;%20&quot;) ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
Get the location of the start of the escape sequence.
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int escLocation = invalidPath.indexOf(&quot;%&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
( escLocation &gt; 0 ) {</span>
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Store the path starting at the location of the last </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// escape sequence, up to the location of the current</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// escape sequence.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
validPath = validPath + invalidPath.substring( 0, </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
escLocation ) + &quot; &quot;;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// Store the next start location.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nextStart = escLocation + 3;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
else {&nbsp;&nbsp; // There were no more escape sequences.
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
validPath = validPath + invalidPath.substring(nextStart);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
// End of inner if()...else block.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
Truncate invalidPath so that invalidPath.contains(&quot;%20&quot;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
will eventually be false.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
invalidPath = invalidPath.substring(nextStart);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else
{&nbsp;&nbsp; // Since invalidPath doesn't contain any &quot;%20&quot; escape
</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// sequences, we can exit the loop.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
valid = true;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } //
End of outer if()...else loop.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End
of while() loop.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Add the
last bit of invalidPath to our validPath variable.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; validPath
= validPath + invalidPath;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Next,
get rid of the&nbsp; string at the front of the path that ends</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // with :/.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
colonLoc = validPath.indexOf(&quot;:/&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (
colonLoc &gt; 0 ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
Truncate our valid path to the location of the colon plus one.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
validPath = validPath.substring
(colonLoc + 1);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End
if.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<i><b><span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
Lastly, we need to check for the name of our JAR file, as that can</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // cause
a problem.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
jarLoc = validPath.indexOf
(&quot;/Law_Office_Essentials.jar!&quot;);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (
jarLoc &gt; 0 ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
We need to strip our validPath String into to temporary Strings,</span>
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
the one before the jarLoc and the one after the jarLoc.&nbsp; Once</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //
we&#39;ve done that, we can recreate our valid string.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String frontHalf = validPath.substring(0, jarLoc);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String backHalf = validPath.substring
(jarLoc + 27);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
validPath = frontHalf + backHalf;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // End
of JAR removal.</span></b></i><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Return
our validated path string.</span><