public static void main(String[] args) throws Exception 
  {

	
	/* now, let's test out a bunch of say_sentence formats */

        File testxmldir = new File("./testxml");
	File[] xmlfiles = testxmldir.listFiles();
        for ( File fname : xmlfiles )
          {
		if ( fname.isFile() )
                  {
			Socket sock = new Socket("localhost", 9746);
			String n = fname.getName();
			System.out.println("========================= " + n + " =================");
			FileInputStream istream = new FileInputStream(fname);
			OutputStream out = sock.getOutputStream();
			DataOutputStream dout = new DataOutputStream(out);
			long numToSend = fname.length();
			byte[] bytes = new byte[(int)numToSend];
			long numSent = 0;

			int numRead = istream.read(bytes, 0, (int) numToSend);
			if (numRead > 0) dout.write(bytes, 0, numRead);
			System.out.println("Just wrote the request to the output stream");

			InputStream istr2 = sock.getInputStream();

			// Now fetch the response from the server			

                        InputSource isource = new InputSource(istr2);
                        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                        DocumentBuilder db = null;
			Document doc = null;
                        try
                          {
                        	db = dbf.newDocumentBuilder();
				doc = db.parse(isource);
				
			  }
			catch (ParserConfigurationException pce)
			  {
				pce.printStackTrace();
			  }
			catch (SAXException se)
			  {
				se.printStackTrace();
			  }
			catch (IOException ioe)
			  {
				ioe.printStackTrace();
			  }
			Element docElem = doc.getDocumentElement();

			Transformer tr = TransformerFactory.newInstance().newTransformer();
			tr.setOutputProperty(OutputKeys.INDENT, "yes");
			tr.setOutputProperty(OutputKeys.METHOD, "xml");
			tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");

			tr.transform( new DOMSource(doc), new StreamResult(System.out)); /* And OUT she goes! */

			sock.close();
			

			System.out.print("================================================\n");
		  }
	  }
	
  }