把下面这个小例子Copy过去编译运行。
import java.io.*;
public class fileTest {
public fileTest(String filepath) {
try
{
File thePath = new File("C:\\p\\pra\\"+filepath);
if (thePath.isDirectory() == false) {
thePath.mkdirs();
} String fullPath="C:\\p\\pra\\"+filepath+"\\rrrr.txt";
File theFile=new File(fullPath);
if (theFile.exists() == true) {
theFile.delete();
}
theFile.createNewFile();
RandomAccessFile fout = new RandomAccessFile(fullPath, "rw");
fout.writeBytes("I am a Chinese");
fout.close(); }catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
String path=args[0];
fileTest fileTest1 = new fileTest(path);
}}
import java.io.*;
public class fileTest {
public fileTest(String filepath) {
try
{
File thePath = new File("C:\\p\\pra\\"+filepath);
if (thePath.isDirectory() == false) {
thePath.mkdirs();
} String fullPath="C:\\p\\pra\\"+filepath+"\\rrrr.txt";
File theFile=new File(fullPath);
if (theFile.exists() == true) {
theFile.delete();
}
theFile.createNewFile();
RandomAccessFile fout = new RandomAccessFile(fullPath, "rw");
fout.writeBytes("I am a Chinese");
fout.close(); }catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
String path=args[0];
fileTest fileTest1 = new fileTest(path);
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货