大学JAVA实验五
大学JAVA实验五
这一次的实验做的不满意,恳请各位批评,恳请各位提供方法及建议
第一个实验
指定不同协议的URL地址,获得资源文件的内容和属性
URLStudy.java
package first;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.TextArea;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class URLStudy extends JFrame {
private static final long serialVersionUID = 1L;
private Font font = new Font("宋体", Font.CENTER_BASELINE, 13);
TextArea textarea = new TextArea();
JButton button[] = new JButton[3];
String buttonName[] = { "确定", "取消", "保存文件" };
JLabel label = new JLabel("请输入URL地址:");
JTextField urlfield = new JTextField(20);
JPanel panel = new JPanel();
URLStudyListener listener = new URLStudyListener(this);
private String file = "";
private FileDialog filesave;
public URLStudy() {
super.setTitle("资源文件的内容和属性查看器");
ImageIcon icon = new ImageIcon("195032.jpg");//在当前目录下加入名为195032.jpg的图片即可改变窗口左上角的咖啡图片,不愿意改就注释这行与下一行
setIconImage(icon.getImage());
textarea.setFont(font);
label.setFont(font);
urlfield.setFont(font);
panel.add(label);
panel.add(urlfield);
for (int i = 0; i < buttonName.length; i++) {
button[i] = new JButton(buttonName[i]);
button[i].addActionListener(listener);
button[i].setFont(font);
panel.add(button[i]);
}
super.setDefaultCloseOperation(EXIT_ON_CLOSE);
&
相关文档:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BubbleSort {
private static int a[] = new int[12];
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void bubbleSort(int a[], i ......
RMI(Remote Method Invocation)
RMI是分布式对象软件包,它简化了在多台计算机上的JAVA应用之间的通信。
必须在jdk1.1以上
RMI用到的类
java.rmi.Remote 所有可以被远程调用的对象都必须实现该接口
java.rmi.server.UnicastRemoteObject 所有可以被远程调用的对象都必须扩展该类
什么是RMI
远程方法调用是 ......
java 列出某文件夹下的所有文件
import java.io.*;
public class ListFiles {
private static String s = "";
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void main(String[] args) {
try {
s = in.readLine();
ge ......
---------MySql-----
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","username", "password");
--------Access ---------
建立ODBC数据源
Class.forName("sun.jdbc.odbc.J ......
昨天,我的朋友请教我正则表达式。我也好久没有写过正则表达式了,昨天刚好看了下如鹏网创始人杨中科老师关于正则表达式的讲解。使我加深了正则表达式的印像。现我把他总结下:
许多语言,包括Perl、PHP、Python、JavaScript和JScript,都支持用正则 ......