# HG changeset patch # User one # Date 1345679779 -32400 # Node ID 1405a0c97c67a740b2c46728e3b289c77d3eb45b # Parent 84dd614f141466e1acb4dec30825b18b87260332 fix LinkConvertGraph.java diff -r 84dd614f1414 -r 1405a0c97c67 src/wikigraph/LinkConvertGraph.java --- 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> 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> hash; - hash = xmlParser.getHash(); -*/ - - } catch (FileNotFoundException e) { e.printStackTrace();