package HX;
import java.net.URL;
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(new DataInputStream(new FileInputStream ("////home//rakesh//stuff//index.html" )));
out = new FileOutputStream("////home//rakesh//stuff//mn.xml");
//Convert files
System.out.println("111111111111111");
tidy.parse(in, out);
System.out.println("555555555");
//Clean up
in.close();
out.close();
} catch (IOException e) {
System.out.println(this.toString() + e.toString());
}
}
public static void main(
String[] args) throws IOException {
TestHTML2XML_1 t = new TestHTML2XML_1();
t.convert();
File f=new File("////home//rakesh//stuff//myshell.sh");
FileOutputStream fos=new FileOutputStream(f);
OutputStreamWriter os=new OutputStreamWriter(fos);
os.write("cd /home");
os.write("cd rakesh");
os.write("cd stuff");
os.write("tidy -asxhtml -numeric ///home//rakesh//stuff//index.html //home//rakesh//stuff//index.xml"); os.close();
fos.close();
Runtime rt=Runtime.getRuntime();
Process p=rt.exec("/myshell.sh"); System.out.println("rrrr");
}
}
----------------------
1) the class converts HTML file to XML
1) scenario is that am writing some commands in .sh file through
java code and close it.
2) now if i give the command on command line (which is shown in bold) its generating XML....No problem..
3) but i waaant to run that command from java code itself (as shown in ITALICS. so i write that command in .sh file so as ill execute that .sh file from with in the programm insted from command prompt. and as soon as execute method ends i am expecting my XML to be generated there.
Please help me...........I AM ON GUN POINT.........