Re: Help Help, I am intermediate in Java...need help in follow case
ElementX wrote:
On Oct 1, 1:24 pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
wrote:
ElementX wrote:
On Oct 1, 12:42 pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
wrote:
ElementX wrote:
There is two java classes
second class is for execute ant file.
First Class does the most.
first create a plain class which accepts two java.io.File object in
constructor as input and output and a method which performs
replacement.
- the replacement must take into account the file ending of the input
file:
+ for .java, .cpp, .c and .css remove the FIRST occurrence of "/
* ... */"
+ for .xml, .xhtml, .html and .xsl remove the FIRST occurrence of
"<!-- ...
-->"
has any body have an example class to do it?
Thanks a lot...if you can help...I create a class but is not
working...maybe I can post it here...
Do post it here. It would help if you explain *exactly* what you mean by
"is not working".
--
RGB
the following code was wrote for mappings in jar file...maybe can
help...
[code omitted]
If you wrote that then you are skilled enough in Java that you don't
need my help.
If I were tackling the assignment you describe, I would not start with
the code you posted. I'd start from scratch.
Assuming you didn't in fact write the code you posted, you might find
Patricia's guide helpful:http://home.earthlink.net/~patricia_shanahan/beginner.html
I'd start with the requirement "first create a plain class which accepts
two java.io.File object in constructor as input". From this I'd write
class ReplaceFirstComment {
ReplaceFirstComment(File input, File output) {
// TODO
}
}
Then I'd compile it and test it. I'd not move on until I was entirely
happy with the test results and had eliminated any compiler warnings.
Then I'd think about the next tiny change that I could make that I could
compile and test.
--
RGB
Do you have an idea...or an example file...which can help more
My idea was you take my starting point (above) and build on it step by step.
Here's how I imagined proceeding ...
----------------------------------------------------
C:\temp>type ReplaceFirstComment.java
class ReplaceFirstComment {
ReplaceFirstComment(File input, File output) {
// TODO
}
}
C:\temp>javac ReplaceFirstComment.java
ReplaceFirstComment.java:2: cannot find symbol
symbol : class File
location: class ReplaceFirstComment
ReplaceFirstComment(File input, File output) {
^
ReplaceFirstComment.java:2: cannot find symbol
symbol : class File
location: class ReplaceFirstComment
ReplaceFirstComment(File input, File output) {
^
2 errors
----------------------------------------------------
OK so we need to fix those errors ...
----------------------------------------------------
C:\temp>type ReplaceFirstComment.java
import java.io.*;
class ReplaceFirstComment {
ReplaceFirstComment(File input, File output) {
// TODO
}
}
C:\temp>javac ReplaceFirstComment.java
C:\temp>
----------------------------------------------------
It compiles, now to test it, it should do nothing, does it?
----------------------------------------------------
C:\temp>java ReplaceFirstComment.java
Exception in thread "main" java.lang.NoClassDefFoundError:
ReplaceFirstComment/java
Caused by: java.lang.ClassNotFoundException: ReplaceFirstComment.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
C:\temp>
----------------------------------------------------
Oh, we are missing a "main" method. We need to add some sort of test
harness, so I'll deal with both issues the simplest way.
----------------------------------------------------
C:\temp>type ReplaceFirstComment.java
import java.io.*;
class ReplaceFirstComment {
ReplaceFirstComment(File input, File output) {
// TODO
}
public static void main (String[] args) {
File input = new File(args[0]);
File output = new File(args[1]);
new ReplaceFirstComment(input, output);
}
}
C:\temp>javac ReplaceFirstComment.java
C:\temp>java ReplaceFirstComment ReplaceFirstComment.java Replaced.java
C:\temp>
----------------------------------------------------
OK, test sucessful? - your turn.
At this point you may be thinking "Hey RGB, I'm an intermediate Java
programmer and I know all this stuff, it's trivial, why are you wasting
your and my time with it?"
The point is you haven't followed this process else you'd have some
small example code that is more developed than this and shows us where
you got stuck.
So what have you come up with so far?
--
RGB