在网吧从超星上下了一本书,考回来看既然要离线注册码,真不爽!

okwuzhijun 2005-05-18 09:31:06
在网吧从超星上下了一本书,考回来看既然要离线注册码,真不爽!
...全文
155 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
okwuzhijun 2005-06-15
  • 打赏
  • 举报
回复
public class FileOperator {
private FileOperator() {}

/**
* Function: move file(only move file)
* parameter: strSourceFileName:specified completed file path
* strDestDir: move to specified folder
* return: success true; faild false
*/
public static boolean copy(String sourceFileName,
String destDir) {
File fileSource = new File(sourceFileName);
File fileDest = new File(destDir);

//if the source file don't exist or it is folder, return false
if (!fileSource.exists() || fileSource.isDirectory()) {
return false;
}

// if target folder dosn't exist
if (!fileDest.isDirectory() || !fileDest.exists()) {
if (!fileDest.mkdirs()) {
return false;
}
}

FileInputStream fin = null;
FileOutputStream fout = null;
try {
String strDestFilename = destDir + File.separator
+ fileSource.getName();

fin = new FileInputStream(sourceFileName);
FileChannel in = fin.getChannel();

// Now get the output channel
WritableByteChannel out;
fout = new FileOutputStream(strDestFilename); // open file stream
out = fout.getChannel(); // get its channel

long numbytes = in.size();
in.transferTo(0, numbytes, out);

return true;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
try {
if (fin != null)
fin.close();
if (fout != null)
fout.close();
} catch (IOException e) {}
}
}

/**
* functin: delete specified file parameter: completed file path's file name
* strFileName retrun: delete success true faild false;
*/
public static boolean delete(String fileName) {
File fileDelete = new File(fileName);

if (!fileDelete.exists()) {
return false;
}

return fileDelete.delete();
}

public static boolean move(String sourceFileName, String destDir,
boolean isOverwrite) {
File sourceFile = new File(sourceFileName);
File desFile = new File(destDir + File.separator + sourceFile.getName());

if (isOverwrite) {
if (desFile.exists()) {
desFile.delete();
}
}

return sourceFile.renameTo(desFile);
}

public static boolean move(String sourceFileName, String destDir) {
return move(sourceFileName, destDir, false);
}

/**
* function: create folder
* parameter: strDir folder name of by created
* return : success true; fail false
*/
public static boolean mkdir(String strDir) {
File fileNew = new File(strDir);

if (!fileNew.exists()) {
return fileNew.mkdirs();
} else {
return true;
}
}

/**
* function: delete folder
* parameter: strDir deleted folder name
* return: success true; fail false
*/
public static boolean rmdir(String strDir) {
File rmDir = new File(strDir);
if (rmDir.isDirectory() && rmDir.exists()) {
String[] fileList = rmDir.list();

int size = fileList.length;
for (int i = 0; i < size; i++) {
String subFile = strDir + File.separator + fileList[i];
File tmp = new File(subFile);
if (tmp.isFile()) {
tmp.delete();
} else if (tmp.isDirectory()) {
rmdir(subFile);
} else {
throw new RuntimeException(tmp.getAbsolutePath()
+ "is not file or directory.");
}
}
rmDir.delete();
} else {
return false;
}
return true;
}

/**
* del all files
*
* @param strDir
* @return
*/
public static boolean delDirFilse(String strDir) {
return delDirFilse(strDir, new String[] {""});
}

public static boolean delDirFilse(String strDir, String[] suffixes) {
File rmDir = new File(strDir);
if (rmDir.isDirectory() && rmDir.exists()) {
String[] fileList = rmDir.list();

int size = fileList.length;
for (int i = 0; i < size; i++) {
String subFile = strDir + File.separator + fileList[i];
File tmp = new File(subFile);
if (tmp.isFile()) {
for (int j = 0; j < suffixes.length; j++) {
if (subFile.endsWith(suffixes[j])) {
tmp.delete();
break;
}
}
} else if (tmp.isDirectory()) {
delDirFilse(subFile, suffixes);
} else {
throw new RuntimeException(tmp.getAbsolutePath()
+ "is not file or directory.");
}
}
} else {
return false;
}
return true;
}
}
zjlang 2005-05-18
  • 打赏
  • 举报
回复
哈哈,乌龙.....
mituzhishi 2005-05-18
  • 打赏
  • 举报
回复
告诉你怎么读那本书,

用这个浏览器:

http://down.chinaz.com/s/14007.asp
yjh1982 2005-05-18
  • 打赏
  • 举报
回复
C++版的版主呢?这人把这种论题发在技术区,然后还给我发消息呢:




编号: 134 发送者 Cnwanglin 发送时间 2005-5-18 9:56:27 删除 回复
内容 hello

can you tell me how old are you ?




okwuzhijun 2005-05-18
  • 打赏
  • 举报
回复
跟不知道的人当然没有关系!C++分坛就没人看超星的书吗?
yjh1982 2005-05-18
  • 打赏
  • 举报
回复
跟C++分坛又关系吗?

64,632

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧