Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Creating XML file from java program(I want to create xml file from java program in Eclipse)
Creating XML file from java program [message #891664] Mon, 25 June 2012 12:52
Rahul Deshmukh is currently offline Rahul DeshmukhFriend
Messages: 2
Registered: June 2012
Junior Member
Please any one help in how to create xml file from the above java program code

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/**
* @author mh
* @since 13.01.12
*/
public class TestDataGenerator {

private static int NODES = 75 * 1000; // * 1000;
private static final int RELS_PER_NODE = 10;
private static final String[] TYPES = {"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN"};

public static void main(String...args) throws IOException {
Random rnd = new Random();
long relCount=0, time = System.currentTimeMillis();
BufferedWriter nodeFile = new BufferedWriter(new FileWriter("D:\\nodes.xml"));
nodeFile.write("Node\tRels\tProperty\n");
BufferedWriter relFile = new BufferedWriter(new FileWriter("D:\\rels.xml"));
relFile.write("Start\tEnde\tType\tProperty\n");
for (int node = 0; node < NODES; node++) {
final int rels = rnd.nextInt(RELS_PER_NODE);
nodeFile.write(node+"\t"+rels+"\tTEST\n");
for (int rel = rels; rel >= 0; rel--) {
relCount++;
final int node1 = rnd.nextInt(NODES);
final int node2 = rnd.nextInt(NODES);
relFile.write(node1 + "\t" + node2 + "\t" + TYPES[rel] + "\t" + "Property"+ "\n");
}
}
nodeFile.close();
relFile.close();
System.out.println("Creating "+NODES+" and "+relCount+" Relationships took "+((System.currentTimeMillis()-time)/1000)+" seconds.");
}
}
Previous Topic: Eclipse will not start in Ubuntu 12.04 - 64 bits
Next Topic:Executable Jar won't load from command line
Goto Forum:
  


Current Time: Wed Nov 26 04:29:19 GMT 2014

Powered by FUDForum. Page generated in 0.02115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software