private void replyFile(String path) throws Exception
	{
		path = path.replace('/', File.separatorChar);
		File file = new File(path);
		if (!file.exists()) {
			System.err.println("File \"" + path + "\" not found");
			return;
		}
		System.err.println("File \"" + path + "\" found and sent");
        //		FileInputStream in = new FileInputStream(file);


		// String head = "HTTP/1.0 200 OK\r\n";
        // head += "Content-type: " + "image/png" + "\r\n";
		// head += "Content-Length: " + file.length() + "\r\n";
		// OutputStream out = connection.getOutputStream();
		// out.write(head.getBytes());
		// byte[] buf = new byte [4096]; int i;
		// while ((i = in.read(buf)) > 0)
		// 	out.write(buf, 0, i);
		// in.close();

        PrintWriter out = new PrintWriter(connection.getOutputStream());
        BufferedOutputStream dataOut = new BufferedOutputStream(connection.getOutputStream());

        int fileLength = (int)file.length();
        byte[] fileData = new byte[fileLength];
        FileInputStream fileIn = new FileInputStream(file);
        fileIn.read(fileData);
        fileIn.close();

        //send HTTP headers
        out.println("HTTP/1.0 200 OK");
        out.println("Server: Java HTTP Server 1.0");
        //      out.println("Content-type: " + "image/png");
        out.println("Content-length: " + file.length());
        out.println(); //blank line between headers and content
        out.flush(); //flush character output stream buffer

        dataOut.write(fileData,0,fileLength); //write file
        dataOut.flush(); //flush binary output stream buffer
        
        out.close();
        dataOut.close();
		connection.close();
	}