标签:-- eve windows wrap nbsp comment .net The element
1----------------
boolean makedir 创建文件夹 048 a97 A65
boolean makedirs 创建文件夹
boolean creatfile 创建文件
boolean delete 删除文件 删除的文件不能包含其他文件
boolean renameTo(File dest) 相同路径是复制 不同路径是改名+剪切
-----------1----------------boolean makedir 创建文件夹 048 a97 A65boolean makedirs 创建文件夹boolean creatfile 创建文件boolean delete 删除文件 删除的文件不能包含其他文件boolean renameTo(File dest) 相同路径是复制 不同路径是改名+剪切----------- System.out.println("exists:"+file.exists());//是否存在
System.out.println("isDirectory:"+file.isDirectory());//是否是目录
System.out.println("isHidden:"+file.isHidden());//是否隐藏
System.out.println("isCanWrite:"+file.canWrite());//是否能写
System.out.println("isCanRead:"+file.canRead());//是否能读 System.out.println("exists:"+file.exists());//是否存在 System.out.println("isDirectory:"+file.isDirectory());//是否是目录 System.out.println("isHidden:"+file.isHidden());//是否隐藏 System.out.println("isCanWrite:"+file.canWrite());//是否能写 System.out.println("isCanRead:"+file.canRead());//是否能读*getAbsolutePath()() 获取绝对路径
* getPath() 获取x相对路径
* getName()获取名字
* long length()获取文件大小 用毫秒来表示
* Date date = new Date(file.lastModified());
SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yy-MM-dd HH:mm:ss");
String str=simpleDateFormat.format(date);
System.out.println(str);
file类的高级获取功能
File file = new File("mljqqh");
//匿名内部类
File[] files = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().endsWith(".jpg");
}
});
for (File file1 : files) {
System.out.println(file1.getAbsolutePath());
}
//lambda方式
File[] files = file.listFiles(pathname -> pathname.isFile() && pathname.getName().endsWith(".jpg"));
for (File file1 : files) {
System.out.println(file1.getAbsolutePath());
}
}
}
*getAbsolutePath()() 获取绝对路径* getPath() 获取x相对路径* getName()获取名字* long length()获取文件大小 用毫秒来表示* Date date = new Date(file.lastModified());SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yy-MM-dd HH:mm:ss");String str=simpleDateFormat.format(date);System.out.println(str);file类的高级获取功能 File file = new File("mljqqh"); //匿名内部类 File[] files = file.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().endsWith(".jpg"); } }); for (File file1 : files) { System.out.println(file1.getAbsolutePath()); }//lambda方式 File[] files = file.listFiles(pathname -> pathname.isFile() && pathname.getName().endsWith(".jpg")); for (File file1 : files) { System.out.println(file1.getAbsolutePath()); } }} fileInputStream类
终极版本读文件
int i=0;
while ((i=fis.read())!=-1){
System.out.print((char)i);
}fileInputStream类终极版本读文件int i=0; while ((i=fis.read())!=-1){ System.out.print((char)i); }FileInputStream fis= new FileInputStream("mljqqh.txt");
FileOutputStream fos= new FileOutputStream("mljqqh1.txt");
int by=0;
while ((by=fis.read())!=-1){
fos.write(by);
}
fis.close();
fos.close();
FileInputStream fis= new FileInputStream("mljqqh.txt"); FileOutputStream fos= new FileOutputStream("mljqqh1.txt"); int by=0; while ((by=fis.read())!=-1){ fos.write(by); } fis.close(); fos.close(); FileInputStream fis= new FileInputStream("mljqqh.txt");
byte [] bys= new byte[1024];
int len;
while ((len=fis.read(bys))!=-1){
System.out.print(new String(bys,0,len)); FileInputStream fis= new FileInputStream("mljqqh.txt"); byte [] bys= new byte[1024]; int len; while ((len=fis.read(bys))!=-1){ System.out.print(new String(bys,0,len));FileOutputStream fos = new FileOutputStream("mljqqh1.txt");
FileInputStream fis = new FileInputStream("mljqqh.txt");
byte[] bys = new byte[1024];
int len=0;
while ((len=fis.read(bys))!=-1){
fos.write(bys,0,len);
}
fis.close();
fos.close();
FileOutputStream fos = new FileOutputStream("mljqqh1.txt"); FileInputStream fis = new FileInputStream("mljqqh.txt"); byte[] bys = new byte[1024]; int len=0; while ((len=fis.read(bys))!=-1){ fos.write(bys,0,len); } fis.close(); fos.close(); //BufferedInputStream 读文件 BufferedInputStream是FileInputStream的 依靠 FileInputStream来装饰 左父右子2
BufferedInputStream bis= new BufferedInputStream(new FileInputStream("mljqqh.txt"));
//第一种方式
// int b=0;
// while ((b=bis.read())!=-1){
// System.out.print((char)b);
// }
//第二种方式
byte[] bys = new byte[1024];
int len=0;
while ((len=bis.read(bys))!=-1){
System.out.println(new String(bys,0,len));
}
bis.close();
//BufferedInputStream 读文件 BufferedInputStream是FileInputStream的 依靠 FileInputStream来装饰 左父右子2 BufferedInputStream bis= new BufferedInputStream(new FileInputStream("mljqqh.txt")); //第一种方式// int b=0;// while ((b=bis.read())!=-1){// System.out.print((char)b);// } //第二种方式 byte[] bys = new byte[1024]; int len=0; while ((len=bis.read(bys))!=-1){ System.out.println(new String(bys,0,len)); } bis.close(); /*
转化流
OutputStreamWriter构造方法
OutputStreamWriter(OutputStream out)
OutputStreamWriter(OutputStream out,string charsetName)
//字符流五种写数据的方法
public write(int ch)//写一个字符 可以写数字 java会自动装换
public write(char[] cha)写一个字符数组
public write(char[] cha,int off,int len)写一个字符数组的一部分
public write(String str)写一个字符串
public write(String str,int off,int len)写一个字符串的一部分
/*转化流OutputStreamWriter构造方法OutputStreamWriter(OutputStream out)OutputStreamWriter(OutputStream out,string charsetName)//字符流五种写数据的方法 public write(int ch)//写一个字符 可以写数字 java会自动装换public write(char[] cha)写一个字符数组public write(char[] cha,int off,int len)写一个字符数组的一部分public write(String str)写一个字符串public write(String str,int off,int len)写一个字符串的一部分 Object 类
Class getClass 返回Class类 Class.name
Tostring 直接输出对象名称就是调用该对象的Tostring()Object 类Class getClass 返回Class类 Class.name Tostring 直接输出对象名称就是调用该对象的Tostring()==
基本类型:比较的是值
引用类型:比较的是地址
------------------------------------
eauals
Object类中比较的是对象的地址
String 类对equal进行了重新,比较的是字符串的值==基本类型:比较的是值引用类型:比较的是地址------------------------------------eaualsObject类中比较的是对象的地址String 类对equal进行了重新,比较的是字符串的值Cloneable是一个标记接口
被克隆的对象需要继承这个接口
Student stu=new Student("林青霞",28);
System.out.println("stu的名字:" + stu.getName());
Object obj=stu.clone();
if (obj instanceof Student){
Student stu1=(Student)obj;
stu1.setName("周星驰");
System.out.println("stu的名字:" + stu1.getName());
}
*/
Cloneable是一个标记接口被克隆的对象需要继承这个接口Student stu=new Student("林青霞",28); System.out.println("stu的名字:" + stu.getName()); Object obj=stu.clone(); if (obj instanceof Student){ Student stu1=(Student)obj; stu1.setName("周星驰"); System.out.println("stu的名字:" + stu1.getName()); } */ 判断功能
boolean contains();判断大字符串是否包含小字符串
String substing (int start ,int end)包左不包右
13字符串的装换功能
byte[] gteByte() //把字符串装换成字节数组
char[] toCharArray()把字符串装换成字符数组
static String valueOf(char{} chr)//把字符数组装换成字符串
//static String valueOf(int i) 把int装换成字符串
14String的其他功能
/*
替换功能
String replace(char old,char new)
String replace(String old,String new)
去除字符串两端空格
String trim()
按照字典比较两个字符串
int compareto()
int compareToIgnoreCase()
分割功能 Sring[] split 如果分割的字符串出现在首位,那么分割的数组【0】是""
.前面加上\\进行转义
String作为参数传递 跟基本类型一个效果
*/
判断功能boolean contains();判断大字符串是否包含小字符串String substing (int start ,int end)包左不包右13字符串的装换功能byte[] gteByte() //把字符串装换成字节数组char[] toCharArray()把字符串装换成字符数组static String valueOf(char{} chr)//把字符数组装换成字符串//static String valueOf(int i) 把int装换成字符串14String的其他功能/*替换功能String replace(char old,char new)String replace(String old,String new)去除字符串两端空格String trim()按照字典比较两个字符串int compareto()int compareToIgnoreCase()分割功能 Sring[] split 如果分割的字符串出现在首位,那么分割的数组【0】是"" .前面加上\\进行转义String作为参数传递 跟基本类型一个效果 */ https://blog.csdn.net/qq_37025445/article/details/76563133
集合功能的概述:
a.添加功能
boolean add(E e)
boolean addAll(Collection e )//添加一个集合
b删除功能
void clear()//删除所用功能
c判断功能
boolean contains(E e)
boolean contains( Collection e )
remove(E e)
removeAll(Collection e)移除一个集合
boolean isEmpty()//判断集合是否是空
d获取功能`
iteractor//集合的专用遍历方式 两个方法 hasnext() next(0
e长度功能
size()
f交集功能
boolean retainAll(Colletion e)//两个集合的交集 A对B做交集 ,结果保存在a中 b不变 返回的是a是否发生过变化
g转换功能
Object toArrary()https://blog.csdn.net/qq_37025445/article/details/76563133集合功能的概述:a.添加功能boolean add(E e)boolean addAll(Collection e )//添加一个集合b删除功能void clear()//删除所用功能c判断功能boolean contains(E e)boolean contains( Collection e )remove(E e)removeAll(Collection e)移除一个集合boolean isEmpty()//判断集合是否是空d获取功能`iteractor//集合的专用遍历方式 两个方法 hasnext() next(0e长度功能size()f交集功能boolean retainAll(Colletion e)//两个集合的交集 A对B做交集 ,结果保存在a中 b不变 返回的是a是否发生过变化g转换功能Object toArrary()泛型:
泛型三种:
[1]ArrayList<T> al=new ArrayList<T>();指定集合元素只能是T类型
[2]ArrayList<?> al=new ArrayList<?>();集合元素可以是任意类型,这种没有意义,一般是方法中,只是为了说明用法
[3]ArrayList<? extends E> al=new ArrayList<? extends E>();
泛型的限定:
? extends E:接收E类型或者E的子类型。
?super E:接收E类型或者E的父类型。泛型:泛型三种: [1]ArrayList<T> al=new ArrayList<T>();指定集合元素只能是T类型 [2]ArrayList<?> al=new ArrayList<?>();集合元素可以是任意类型,这种没有意义,一般是方法中,只是为了说明用法 [3]ArrayList<? extends E> al=new ArrayList<? extends E>(); 泛型的限定: ? extends E:接收E类型或者E的子类型。 ?super E:接收E类型或者E的父类型。方式一:对象.getClass() 方法是 根对象Object的方法。 是其他类继承Object的getClass方法。
方式二:类名.class,你可以理解为字节码本身就是静态的,类加载的时字节码就进JVM了。所以类.class好比类调用静态方法似得调用字节码对象。
方式三:Class.forName()是Class类的静态方法。参数是字符串,字符串是类的全路径名。方式一:对象.getClass() 方法是 根对象Object的方法。 是其他类继承Object的getClass方法。 方式二:类名.class,你可以理解为字节码本身就是静态的,类加载的时字节码就进JVM了。所以类.class好比类调用静态方法似得调用字节码对象。 方式三:Class.forName()是Class类的静态方法。参数是字符串,字符串是类的全路径名。标签:-- eve windows wrap nbsp comment .net The element
原文地址:https://www.cnblogs.com/mljqqh/p/10493761.html