📄 outputstream.jsp
字号:
<!--outputstream.jsp-->
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<%!
public String codeString(String s){
String str=s;
try{
byte b[]=str.getBytes("ISO-8859-1");
str=new String (b);
return str;
}catch(Exception e){
return "error";
}
}
%>
<html>
<head>
<title>OutputStream</title>
</head>
<body>
<h1>
<%
String name=request.getParameter("text");
if(name==null)name="";
name=codeString(name);
if(!name.equals("")){
try{
File myfile=new File("E:/temp1/outputstream.txt");
FileOutputStream fout=new FileOutputStream(myfile);
BufferedOutputStream bufferout=new BufferedOutputStream(fout);
byte b[]=name.getBytes();
bufferout.write(b);
bufferout.flush();
bufferout.close();
fout.close();
out.print("OutputStream Test OK!");
}
catch(IOException e){
out.print("error!");
}
}
else{
%>
<form action="outputstream.jsp" method="post" name="form">
您的名字<input type="text" value="" name="text">
<input type="submit" value="发送" name="submit">
</form>
<%
}
%>
</h1>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -