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

📄 success1.jsp

📁 在线考试系统
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK" %>
<%@page import="java.io.*"%>
<%@page import="com.gton.bean.db.*"%>

<html>
<head>
<title>
success
</title>
</head>
<body bgcolor="#ffffff">
 <%
String fileName=null;
try{
InputStream in=request.getInputStream();
String tempFileName=(String)session.getId();

File f1=new File("f:/",tempFileName);
FileOutputStream ou=new FileOutputStream(f1);
byte b[]=new byte[1000];
int n;
while((n=in.read(b))!=-1)
{
   ou.write(b,0,n);
}
  ou.close();
  in.close();
  RandomAccessFile random=new  RandomAccessFile(f1,"r");
  
  int second=1;
  String secondLine=null;
  while(second<=2)
  {
  	secondLine=random.readLine();
  	second++;
  }
  int position=secondLine.lastIndexOf("\\");
  fileName=secondLine.substring(position+1,secondLine.length()-1);
  byte cc[]=fileName.getBytes("ISO-8859-1");
  fileName=new String(cc);

  session.setAttribute("name",fileName);
  
  String uploaddir=request.getSession().getServletContext().getRealPath("/testUpload");
  
  File f2=new File(uploaddir,fileName);
  
  RandomAccessFile random2=new  RandomAccessFile(f2,"rw");
  random.seek(0);
  long forthEndPosition=0;
  
  int forth=1;
  
  while((n=random.readByte())!=-1&&(forth<=4))
  {
  if(n=='\n')
  {
  	forthEndPosition=random.getFilePointer();
  	forth++;
  }
  }
  
  random.seek(random.length());
  long endPosition=random.getFilePointer();
  long mark=endPosition;
  int j=1;
  while((mark>=0)&&(j<=6))
  {
	  mark--;
	  random.seek(mark);
	  n=random.readByte();
	  if(n=='\n')
  	  {
	  	endPosition=random.getFilePointer();
	  	j++;
      }
  }
  random.seek( forthEndPosition);
  long startPoint=random.getFilePointer();
  while(startPoint<endPosition-1)
  	{
	  n=random.readByte();
	  
	  random2.write(n);
	  startPoint=random.getFilePointer();
  	}
	random2.close();
	random.close();
	f1.delete();
}
catch(IOException ee)
{
	out.print("文件上传失败");
}
%>
<br>
<br>
<center>
<h1>交卷成功!</h1>
<hr>
</center>
</body>
</html>

⌨️ 快捷键说明

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