import java.io.*;

public class HelloWorld {

	//Main method.
public static void main(String[] args) {
CreateFile();
ListFileName();
ShowSeparator();
} //Create a file.
//Judge that the file exists.
public static void CreateFile() {
File f = new File("d:\\hello.xt");
try {
if (!f.exists()) {
f.createNewFile();
System.out.println("File created successfully.");
} else {
f.delete();
f.createNewFile();
System.out.println("File exists! File is created again.");
}
} catch (Exception e) {
e.printStackTrace();
}
} //Get file name of all for loop.
public static void ListFileName()
{
String _fileName="D:"+File.separator;
File _fileObj=new File(_fileName);
File[] _fileList=_fileObj.listFiles();
for(File _file : _fileList)
{
System.out.println(_file.getName()+"\n");
}
} //Separator is applyed to different system. For example,windows,linux and so on.
public static void ShowSeparator()
{
System.out.println("file:"+File.separator+"\n"+"path:"+File.pathSeparator);
}
} 本文由fang_beny原创,转载请注明出处。

  

最新文章

  1. 【BZOJ】【2565】最长双回文串
  2. YouTube上的版权保护
  3. requirejs 打包参数
  4. Symmetry(对称轴存在问题)
  5. cf B. Fox Dividing Cheese
  6. BZOJ 2599 Race(树分治)
  7. vc 基于对话框多线程编程实例——线程之间的通信
  8. SQL CRUD 简单查询
  9. 原生ajax实现http请求
  10. FastJson对于JSON格式字符串、JSON对象及JavaBean之间的相互转换
  11. 用LSTM分类 MNIST
  12. python 实现多层目录文件查找
  13. vue-输入框change事件并获取值
  14. MySQL---DDL+DQL---(四)
  15. apache beam ElasticSearchIO 遇到异常后job中断执行 自己定制beam IO
  16. [git与github]__git与github简单了解
  17. 什么是PAGELATCH和PAGEIOLATCH
  18. TSQL:判断某较短字符串在较长字符串中出现的次数。
  19. JDBC 与 Bean Shell的使用(二)获取值,并且断言
  20. 自己搞了20万张图片100个分类,tensorflow训练23万次后。。。。。。

热门文章

  1. Kwickserver
  2. 怎样设置gephi可画大规模网络图形
  3. JAVA反射机制--怎么不受泛型束缚给数组赋值
  4. windows pip源
  5. Linux网络编程中tcp_server和tcp_client函数的封装
  6. Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
  7. hdu4930 Fighting the Landlords(模拟 多校6)
  8. 【Excle数据透视表】如何在Excle中使用数据鼠标拖放
  9. JavaScript Array pop(),shift()函数
  10. ORACLE截取字符串