import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.*; import java.net.*; import java.util.*; public class ReadRemoteInfo extends Applet implements ActionListener { private TextArea ta = new TextArea(); private TextField tf = new TextField(); public void init() { setLayout(new BorderLayout()); add(tf, "North"); add(ta, "Center"); ta.setFont(new Font("Courier", Font.PLAIN, 12)); tf.requestFocus(); tf.addActionListener(this); } public void actionPerformed(ActionEvent ae) { URL u = null; URLConnection c = null; try { String urlStr = tf.getText(); u = new URL(urlStr); c = u.openConnection(); c.connect(); ta.setText(""); ta.append("URL: " + urlStr + "\n"); ta.append(" Content type : " + c.getContentType() + "\n"); ta.append(" Content encoding : " + c.getContentEncoding() + "\n"); ta.append(" Content length : " + c.getContentLength() + "\n"); ta.append(" Date : " + new Date(c.getDate()) + "\n"); ta.append(" Last modified : " + new Date(c.getLastModified()) + "\n"); ta.append(" Expiration date : " + new Date(c.getExpiration()) + "\n"); } catch(Exception e) { ta.append("Problem\n"); ta.append(e.getMessage() + "\n"); } } }