(转载)
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)的更多相关文章

  1. 30天C#基础巩固------面向鸭子编程,关于string和File的练习

         面向对象编程就是面向抽象的父类进行编程,具体的实现不用考虑,由子类决定.<经典的说法--面向鸭子编程> eg:鸭子的编程,<对于多态的理解>     我们都习惯把使用 ...

  2. String inputStream file转化

    String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...

  3. Junit 注解 类加载器 .动态代理 jdbc 连接池 DButils 事务 Arraylist Linklist hashset 异常 哈希表的数据结构,存储过程 Map Object String Stringbufere File类 文件过滤器_原理分析 flush方法和close方法 序列号冲突问题

    Junit 注解 3).其它注意事项: 1).@Test运行的方法,不能有形参: 2).@Test运行的方法,不能有返回值: 3).@Test运行的方法,不能是静态方法: 4).在一个类中,可以同时定 ...

  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””] ...

  5. Java InputStream、String、File相互转化

    String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...

  6. Java InputStream、String、File相互转化 --- good

    String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...

  7. string str = File.ReadAllText(@"c:\temp\ascii.txt");

    string str = File.ReadAllText(@"c:\temp\ascii.txt");

  8. 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 ...

  9. IO:File类(java.io.File)

    public class File extends Object implements Serializable, Comparable<File> 构造方法: public File(S ...

随机推荐

  1. C10K

    参考 https://www.jianshu.com/p/ba7fa25d3590

  2. project5 大数据

    [概念] build和run不是一样的,要看输出,不要误解. [方法论] 先要搞懂每个方法的使用,不能乱写.文件名不要写成字符串内容. 又忘记用lab code了,该死. programcreek是个 ...

  3. 实用矩阵类(Matrix)(带测试)

    引言: 无意间看到国外一个网站写的Matrix类,实现了加减乘除基本运算以及各自的const版本等等,功能还算比较完善,,于是记录下来,以备后用: #ifndef MATRIX_H #define M ...

  4. Java并发编程之并发容器

    解决并发情况下的容器线程安全问题的.给多线程环境准备一个线程安全的容器对象. 线程安全的容器对象: Vector, Hashtable.线程安全容器对象,都是使用 synchronized 方法实现的 ...

  5. Python数据库连接池DBUtils

    Python数据库连接池DBUtils   DBUtils是Python的一个用于实现数据库连接池的模块. 此连接池有两种连接模式: 模式一:为每个线程创建一个连接,线程即使调用了close方法,也不 ...

  6. Git命令参考手册

    git init # 初始化本地git仓库(创建新仓库) git config --global user.name "xxx" # 配置用户名 git config --glob ...

  7. 10.spring-boot基于角色的权限管理页面实现

    10.spring-boot基于角色的权限管理页面实现

  8. 1、背景介绍及移动云MAS平台 --短信平台

    目的: 刚开发完成一套短信平台以及一个Web端短信发送系统,短信平台耗时两个周.短信发送系统耗时两个多月,开发使用的技术没什么高科技含量,在此主要是记录下很多情况的处理方案,希望能让大家提出改善方案和 ...

  9. todolist---插入和删除----vue

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. UVa10474

    #include <bits/stdc++.h> using namespace std; ; int main() { int n,q,x; ; int a[maxn]; while(c ...