Mercurial > hg > Members > nobuyasu > TestNeo4j
changeset 14:1405a0c97c67 draft
fix LinkConvertGraph.java
author | one |
---|---|
date | Thu, 23 Aug 2012 08:56:19 +0900 |
parents | 84dd614f1414 |
children | fa38ded4c054 |
files | src/wikigraph/LinkConvertGraph.java |
diffstat | 1 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/wikigraph/LinkConvertGraph.java Thu Aug 23 07:22:37 2012 +0900 +++ b/src/wikigraph/LinkConvertGraph.java Thu Aug 23 08:56:19 2012 +0900 @@ -4,6 +4,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; @@ -61,31 +62,38 @@ for (String link : entry.getValue()) { System.out.println("\t"+link); } + System.out.println(); + } + } + + private void printHash(FileOutputStream os) throws IOException { + for (Map.Entry<String,HashSet<String>> entry : hash.entrySet()) { + String title = entry.getKey(); + os.write( ("title: " + title + "\n").getBytes()); + for (String link : entry.getValue()) { + os.write( ("\t"+link+"\n").getBytes()); + } + os.write( ("\n").getBytes()); + os.flush(); } } public static void main(String[] args) { final String filename = "./resource/article3.xml"; +// final String filename = "~/testProgram/wiki/ja-pages_current.xml"; + try { LinkConvertGraph lcg = new LinkConvertGraph(filename); lcg.parseXml(); - lcg.printHash(); - - - /* - FileInputStream fis = new FileInputStream(filename); - TestSaxParser xmlParser = new TestSaxParser(); - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser parser = factory.newSAXParser(); + final String logFile = "./resource/log2.txt"; + FileOutputStream os = new FileOutputStream(logFile); + + lcg.printHash(os); + os.close(); +// lcg.printHash(); - parser.parse(fis, xmlParser ); - HashMap<String,HashSet<String>> hash; - hash = xmlParser.getHash(); -*/ - - } catch (FileNotFoundException e) { e.printStackTrace();