Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-20-2009, 08:08 PM
Member
 
Join Date: Nov 2009
Posts: 1
Rep Power: 0
shantimudigonda is on a distinguished road
Default Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
Hi All,

I am new to Java, I have written a program where i am getting the error

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

here is the code.

import java.net.URL;
import java.io.*;
import org.w3c.tidy.Tidy;

public class TestHTML2XML {
private String url;
private String outFileName;
private String errOutFileName;

public TestHTML2XML(String url, String outFileName, String
errOutFileName) {
this.url = url;
this.outFileName = outFileName;
this.errOutFileName = errOutFileName;
}

public void convert() {
URL u;
BufferedInputStream in;
FileOutputStream out;

Tidy tidy = new Tidy();

//Tell Tidy to convert HTML to XML
tidy.setXmlOut(true);

try {
//Set file for error messages
tidy.setErrout(new PrintWriter(new FileWriter(errOutFileName), true));
u = new URL(url);

//Create input and output streams
in = new BufferedInputStream(u.openStream());
out = new FileOutputStream(outFileName);

//Convert files
tidy.parse(in, out);

//Clean up
in.close();
out.close();

} catch (IOException e) {
System.out.println(this.toString() + e.toString());
}
}

public static void main(String[] args) {
/*
* Parameters are:
* URL of HTML file
* Filename of output file
* Filename of error file
*/
System.out.println("url" + args[0]);
System.out.println("abc.xml" + args[1]);
System.out.println("123.xml" + args[2]);
TestHTML2XML t = new TestHTML2XML(args[0], args[1], args[2]);
t.convert();
}
}


Please help me out where i am doing wrong.

thanks in advance.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-20-2009, 08:58 PM
Senior Member
 
Join Date: Sep 2008
Location: Voorschoten, the Netherlands
Posts: 1,269
Rep Power: 3
JosAH is on a distinguished road
Default
My guess: you're not passing any parameters to your main( ... ) method.

kind regards,

Jos

ps. the exception also tells you exactly where the error happened; look there.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link kavitha_0821 New To Java 6 07-16-2009 04:30 PM
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link kavitha_0821 New To Java 1 07-16-2009 11:35 AM
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException paul New To Java 5 03-28-2009 06:16 AM
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main barney New To Java 1 08-07-2007 08:10 AM
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException romina New To Java 1 07-25-2007 11:55 PM


All times are GMT +2. The time now is 11:52 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org