File(File f, String child) File(String parent, String child)
(转载)
File(File f, String child)
根据f 抽象路径名和 child 路径名字符串创建一个新 File 实例。
f抽象路径名用于表示目录,child 路径名字符串用于表示目录或文件
f - 父抽象路径名
child - 子路径名字符串 File(String parent, String child)
根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例。
parent 路径名字符串用于表示目录,child 路径名字符串用于表示目录或文件
parent - 父路径名字符串
child - 子路径名字符串
在java中,目录也是一种文件,可以像创建文件一样创建目录文件:
1: File f = new File("F:\\java\\rose");
(其中F:\java\rose是一个已经存在的目录),你可以调用file.exists()看目录是否存在,如存在则函数返回true,
如不存在你可以调用 file.mkdir(); 创建rose目录。
2: File file=new(f,“file1.txt”);
可以实例化F:\java\rose目录下的文件file1.txt(文件已存在),你可以调用file.exists()看文件是否存在,
如存在则函数返回true,如不存在你可以调用 file.createNewFile()创建 file1.txt文件。注意,当你实例化
一个已经存在的文件时,一定要加上后缀名,如.txt等,否则实例化的文件是不存在的。调用file.exists()返回false. File f = new File("F:\\java\\rose"); (其中F:\java\rose是一个已经存在的目录)
File file=new(f,“file1.txt”);可以实例化F:\java\rose目录下的文件file1.txt(文件已存在)
具体解释如上所述。
File(File f, String child) File(String parent, String child)的更多相关文章
- 30天C#基础巩固------面向鸭子编程,关于string和File的练习
面向对象编程就是面向抽象的父类进行编程,具体的实现不用考虑,由子类决定.<经典的说法--面向鸭子编程> eg:鸭子的编程,<对于多态的理解> 我们都习惯把使用 ...
- String inputStream file转化
String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...
- Junit 注解 类加载器 .动态代理 jdbc 连接池 DButils 事务 Arraylist Linklist hashset 异常 哈希表的数据结构,存储过程 Map Object String Stringbufere File类 文件过滤器_原理分析 flush方法和close方法 序列号冲突问题
Junit 注解 3).其它注意事项: 1).@Test运行的方法,不能有形参: 2).@Test运行的方法,不能有返回值: 3).@Test运行的方法,不能是静态方法: 4).在一个类中,可以同时定 ...
- Android错误:can not get file data of lua/start_v2.op [LUA ERROR] [string "require "lua/start_v2””] 已解决
错误: can not get file data of lua/start_v2.op [LUA ERROR] [string "require "lua/start_v2””] ...
- Java InputStream、String、File相互转化
String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...
- Java InputStream、String、File相互转化 --- good
String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...
- string str = File.ReadAllText(@"c:\temp\ascii.txt");
string str = File.ReadAllText(@"c:\temp\ascii.txt");
- how to write string to file in bash
how to write string to file in bash https://stackoverflow.com/questions/22713667/shell-script-how-to ...
- IO:File类(java.io.File)
public class File extends Object implements Serializable, Comparable<File> 构造方法: public File(S ...
随机推荐
- iframe父页面获取子页面元素方法
1.window.frames["iframe的id"].contentDocument.getElementsByClassName("mycontainer" ...
- chrome开发者工具实现整站截屏
我们经常要遇到将整个网站作为图片保存下来的情况,而windows系统自带的PrintScreen键只能保存当前屏幕的截图 在chrome浏览器中可以安装第三方的截图插件实现整站截图 今天我们要介绍的方 ...
- mysql学习笔记--go使用mysql
一. 连接数据库 a. //用户名:密码@[连接方式](主机名:端口号)/数据库名 db,_:=sql.Open("mysql","root:7758521123jf@( ...
- jasper打印文件出现空白页面
EG:打印文件结果打印出一片空白 原因:使用了null的数据源而不是JREmptyDataSource 以下为正确代码 public <T> List<JasperPrint> ...
- (纠错)JSP数据库判断是否存在
- Froms 认证 二级域名共享session登录凭证
1. 需要共享的web.config 里需要加添 <authentication mode="Forms"> <forms name="/> &l ...
- 百度地图缩小后marker点的图标移动
遇到的坑:使用百度地图,当地图缩小时,marker点的自定义图标会出现偏移的问题,marker点的信息窗口会出现闪烁问题. 原因:1.anchor是定位点距离图片左上角的偏移量.如果不给anchor的 ...
- rancher的Ingress的文件大小上传限制配置
添加注释 nginx.ingress.kubernetes.io/proxy-body-size
- Quartz.Net进阶之五:TriggerListener 、JobListener 和 SchedulerListener
一.介绍 今天开始学习监听器,就是 Listener,在Quartz.Net 中,主要包含3类的监听器,主要内容包括:TriggerListener .JobListener 和 SchedulerL ...
- L2范数的相关求解
https://blog.csdn.net/u010725283/article/details/79212762