大学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);
&
相关文档:
example: 求5的阶乘。。
如下:
public class Test {
static int multiply(int n){
if(n==1||n==0)
return n;
else
return n*multiply(n-1);
}
public static void main(String[] args){
System.out.println(multiply(10));
}
......
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代码
package utility.structure;
import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
/**
*
* ......
转贴..............
Java基础方面:
0、作用域public,private,protected,以及不写时的区别
答:区别如下:
作用域 当前类 同一package 子孙类 其他package
public √ √ √ √
protected √ √ √ ×
friendly √ √ × ×
private √ &t ......
昨天,我的朋友请教我正则表达式。我也好久没有写过正则表达式了,昨天刚好看了下如鹏网创始人杨中科老师关于正则表达式的讲解。使我加深了正则表达式的印像。现我把他总结下:
许多语言,包括Perl、PHP、Python、JavaScript和JScript,都支持用正则 ......