java中的文件操作
<div class="item-content">java中提供了io类库,可以轻松的用java实现对文件的各种操作。下面就来说一下如何用java来实现这些操作。生成文件时,可用下边的方法来设置流的编码
PrintWriter myFile =new PrintWriter(new OutputStreamWriter(new FileOutputStream(文件名),"gb2312"));
新建目录
[*]<%@ page contentType="text/html;charset=gb2312"%>
[*]<%
[*]//String URL = request.getRequestURI();
[*]String filePath="C:\\测试\\";
[*]filePath=filePath.toString();//中文转换
[*]java.io.File myFilePath=new java.io.File(filePath);
[*]if(!myFilePath.exists())
[*]myFilePath.mkdir();
[*]%>
页:
[1]