Need an urgrent help

Here is my program: I want to generate a xml file from my data . but I could not do it .some one can help me on this problem please.

import java.io.*;

import java.util.HashMap;

import java.util.Iterator;

import java.util.StringTokenizer;

public class XML {

// private final static String CONTENT_FILE =

private final static String STRUCTURE_FILE = "D://structure1.txt";

private final static String OUTPUT_CXML_FILE = "D://dmoz_cxml.xml";

private final static String TEMP_HASH_FILE = "D://hash.tmp";

private final static int STARTING_CLASS_ID = 8;

private final static boolean PROCESS_STRUCTURE = true;

private final static boolean PROCESS_CONTENT = false;

private final static int NODES_INTERVAL_REPORT = 10000;

private final static int DOCS_INTERVAL_REPORT = 100000;

public static void main(String[] args) {

//first parse the structure file

int errs = 0;

String line;

File f = new File(OUTPUT_CXML_FILE);

FileWriter fr = null;

PrintWriter pr = null;

if (f.exists()) f.delete();

try {

f.createNewFile();

fr = new FileWriter(f);

pr = new PrintWriter(fr);

} catch (IOException e) {

e.printStackTrace();

System.exit(-1);

}

pr.println("<?xml version = \"1.0\" encoding= \"UTF-8\"?>");

pr.println("<CtxContent ctxid=\"" + STARTING_CLASS_ID + "\" name=\"DMOZ_full\" description=\"null\" timestamp=\"2006-03-20 12:24:11.656\">");

try {

System.out.println("Processing nodes information...");

int currentNode = 0;

pr.println("<SetOfNodes>");

HashMap<String, String> pathToID = new HashMap<String, String>();

HashMap<String, String> nodesToParents = new HashMap<String, String>();

BufferedReader br = new BufferedReader(new FileReader(STRUCTURE_FILE));

while ((line = br.readLine()) != null) {

currentNode++;

if ((currentNode % NODES_INTERVAL_REPORT) == 0) System.out.println("Processed: " + currentNode + " nodes");

StringTokenizer st = new StringTokenizer(line, "/");

String nodeID = st.nextToken().trim();

String category = st.nextToken().trim();

String path = st.nextToken().trim();

if (pathToID.put(path, nodeID) != null) System.out.println("DUPLICATE NODE!");

//e.g.: <cNode id="39" label="Courses"/>

pr.println("<cNode id=\"" + nodeID + "\" label=\"" + xmlTagEncode(category) + "\"/>");

if (path.lastIndexOf("/") != -1) {

String parentPath = path.substring(0, path.lastIndexOf("/"));

if (nodesToParents.put(nodeID, parentPath) != null) System.out.println("DUPLICATE NODE!");

} else if ("top".equalsIgnoreCase(path)) nodesToParents.put(nodeID, "Top");

}

pr.println("</SetOfNodes>");

System.out.println("Saving DMOZ nn_links information");

pr.println("<SetOfcLinks>");

Iterator it = nodesToParents.keySet().iterator();

while (it.hasNext()) {

String nodeID = (String) it.next();

String parentPath = nodesToParents.get(nodeID);

//e.g.: <cLink sourceNodeId="39" targetNodeId="39"/>

pr.println("<cLink sourceNodeId=\"" + nodeID + "\" targetNodeId=\"" + pathToID.get(parentPath) + "\"/>");

}

pr.println("</SetOfcLinks>");

} catch (FileNotFoundException e) {

e.printStackTrace();

System.exit(-1);

} catch (IOException e) {

e.printStackTrace();

System.exit(-1);

}

}

private static String xmlTagEncode(String xmlToEncode) {

if (xmlToEncode == null) {

return null;

}

StringBuffer out = new StringBuffer(xmlToEncode.length());

for (int t = 0; t < xmlToEncode.length(); t++) {

char c = xmlToEncode.charAt(t);

switch (c) {

case ('&'):

out.append("&");

break;

case ('<'):

out.append("<");

break;

case ('>'):

out.append(">");

break;

default:

out.append(c);

}

}

return out.toString();

}

}

here is my text file:structure1.txt

Top/Science/Earth_Sciences/Atmospheric_Chemistry

Top/Science/Earth_Sciences/Atmospheric_Chemistry/Publications

Top/Science/Earth_Sciences/Atmospheric_Chemistry/Modeling

Top/Science/Earth_Sciences/Atmospheric_Chemistry/Education

Top/Science/Earth_Sciences/Atmospheric_Chemistry/Meetings_and_Organizations

[4549 byte] By [morshed_1471@yahoo.coma] at [2007-11-27 7:39:12]
# 1
can u elaborate upon the problem a bit? as in let us know what is happening in your program and why are u not going for an approach that uses DOM or SAX?
@@CKM@@a at 2007-7-12 19:19:51 > top of Java-index,Java Essentials,Java Programming...
# 2
oh... my... goduse code tags (button called "code" above the post/reply textbox)structure your code> but I could not do it .apart from the fact that you should not be generating xml manually in the first place, what exactly goes wrong?
OnBringera at 2007-7-12 19:19:51 > top of Java-index,Java Essentials,Java Programming...
# 3

1) Use a meaningful subject line. Yours tells us nothing.

2) Don't mention how urgent it is. Nobody here cares, and some will get annoyed and refuse to answer your question. It's 100% guaranteed not to get your question answered any faster.

3) Describe your problem in detail. "Doesn't work" means nothing.

4) When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips[/url] on the message entry page. It makes it much easier to read.

If you can't be bothered to communicate your problem clearly and concisely, why should anybody bother to try to help you?

jverda at 2007-7-12 19:19:51 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks for your answer . what am I trying to do :first : I have a text file .. it is called structure and it contains parsed data from Dmoz branch. Now I want to put this data in my program and generate a XML file.I am using SAX parser. thanks for your answer .
morshed_1471@yahoo.coma at 2007-7-12 19:19:51 > top of Java-index,Java Essentials,Java Programming...
# 5
My program runs but I am not getting out put and cannot put data in xml file .you have seen my text file right? . Using this text file data , I want to generate a xml file.thanksMessage was edited by: morshed_1471@yahoo.com
morshed_1471@yahoo.coma at 2007-7-12 19:19:51 > top of Java-index,Java Essentials,Java Programming...