Java : Getting a list of all system fonts
Created 07 June 2002 00:00
  GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
  String fonts[] = g.getAvailableFontFamilyNames();
  for (int i=0; i < fonts.length; i++) {
    System.out.println(fonts[i]);
  }
JavaDocs
Created 11 June 2002 00:00
Generating javadocs is very easy as long as you comment your code properly. Full help can be obtaining by just type javadoc, but I tend to use the following command when generating my javadocs:
javadoc <packagefolder>*.java -author -d <targetfolder>
which will result in all java files in my packagefolder being documented in the targetfolder.

Comments

All javadoc comments should be between a /** and a */. The following tags can be used:

  • @author - author of a class
  • @param - parameter
  • @return - what the method returns
  • @see - see another method/class e.g. @see #otherMethod will create a hyperlink to another method
  • @throws - for constructors that throw exceptions (methods do not need this - Javadoc takes care of this)
  • @version - version number
  • <code>....</code> tags can be used to identify code-related text (e.g. when referring to a parameter
Java : Handling XML Documents
Created 19 June 2002 00:00
To retrieve values from an XML document, you need to import the following:
  import javax.xml.parsers.*;
  import java.io.*;
  import org.w3c.dom.*;
  import javax.swing.*;
The text within elements is itself seen as a node, so to retrieve values from an XML document:
  Document doc = null;
  try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
      .newDocumentBuilder();
    doc = builder.parse(new FileInputStream(file));
  }
  catch (Exception e) {
    throw new Exception(e.getMessage());
  }
  NodeList nodeList = doc.getElementsByTagName("tagname");
  for (int i=0; i<nodeList.getLength(); i++) {
    Node node = nodeList.item(i);    NodeList list = node.getChildNodes();
    System.out.println(list.item(0).getNodeValue());
  }

To save values to an xml document, you also need to import:

  import javax.xml.transform.*;
  import javax.xml.transform.dom.*;
  import javax.xml.transform.stream.*;

Save the document using a Transformer object:

  try {
    Transformer transformer = TransformerFactory.newInstance()
      .newTransformer();
    DOMSource source = new DOMSource(yourDocument);
    StreamResult result = new StreamResult(yourFile);
    transformer.transform(source, result);
  }
  catch (Exception e) {
    e.printStackTrace();
  }

ASP : Detecting the user's IP Address
Created 25 June 2002 00:00, updated 17 June 2017 10:05
  forwardIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  remoteAddr = Request.ServerVariables("REMOTE_ADDR")

  ' check to see if the user is behind a proxy (forwardIP will be populated)
  If forwardIP = "" then
    Response.Write "Your IP address is: " & remoteAddr
  Else
    Response.Write "Your IP address is: " & forwardIP & "<br>"
    Response.Write "Your proxy address is: " & remoteAddr
  End If