大学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);
&
相关文档:
java 循环打印出某对象所在类的类名和方法
public class A {
public void b(){}
public void c(){}
public void d(){}
public void e(){}
}
import java.lang.reflect.*;
public class StaticTest {
public static void test(Object obj)
{
Class myclass = obj.getClass();
//System.out.prin ......
2009-11-09 15:33:36
文件属性配置类
package cn.sist.file;
public class FileProperty {
private int sysProperty = 0;
private int hiddenProperty = 0;
private int readProperty = 0;
private int arriveProperty = 0;
private boolean changeAll = false;
public FileProperty setC ......
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 ......
import java.util.Random;
public class MathOperators {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//随机数的产生
int[] arr = new int[10];
Random r = new Random();
for (int m = 0; m < arr.length; m++)
{
arr[m] = ......
依旧没有文字说明,只有少量的注释,二叉查找树有很多参考资料,这里就不多说了。下面奉上JAVA代码
package utility.structure;
import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
/**
*
* ......