⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7-9.txt

📁 jsp常用实例讲解
💻 TXT
字号:
<html>
<head>
<title>random access files</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<%@ page import="java.io.*" %>
<body>
<hr>
<%
//定义一个类
class user{
private String name=new String();
private boolean sex;
private int age;
public user(String a,boolean b,int c){
	name=a;
	sex=b;
	age=c;
}
public String getName(){
	return name;
}
public String getSex(){
	String tempstring3=new String();
	if(sex){
		tempstring3="MALE";
	}else{
		tempstring3="FEMALE";
	}
	return tempstring3;
}
public String getAge(){
	String tempstring4=new String();
	tempstring4=tempstring4.valueOf(age);
	return tempstring4;
}
public String getOutStr(){
	String tempstring5=new String();
	tempstring5="name="+getName()+" sex="+getSex()+" age="+getAge();
	return tempstring5;
}
}

String tempstring1=new String();
String tempstring2=new String();
File filenew=new File("d:/back/users.txt"); 
filenew.createNewFile();
RandomAccessFile raf=new RandomAccessFile(filenew,"rw");

user userA=new user("Mike",true,24);
tempstring1=userA.getOutStr();
raf.writeChars(tempstring1);
raf.writeChars("\n");

user userB=new user("Jenny",false,29);
tempstring2=userB.getOutStr();
raf.writeChars(tempstring2);
raf.writeChars("");
out.println("Work compeleted!");
%>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -