package collection;
//字节流 读入数据 一次读入一个
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
//使用字节流 复制文本文件
//复制文本文件 其实就是 把文本文件的内容从一个文件当中读取出来 然后写入到另一个文件
public class Test2 {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("D:\MegaData2022\qmfx.txt");
FileOutputStream fos = new FileOutputStream("D:\MegaData2022\第一.txt");
// 读写数据 复制文本文件 一次读入一个字节 一次写入一个字节
int by;
while((by=fis.read()) != -1)
{
fos.write(by);
}
fos.close();
fis.close();
}
}
//在一个文件当中去读取数据 InputStream对应的FileInputStream
//在另一个文件当中 去写入数据 OutputStream对应的FileOutputStream
package collection;
import java.io.FileInputStream;
import java.io.IOException;
public class Test3 {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("D:\MegaData2022\qmfx.txt");
byte[] by = new byte[1024];
int len;
while((len=fis.read(by))!= -1)
{
System.out.println(new String(by,0,len));
}
fis.close();
}
}
package collection;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test4 {
public static void main(String[] args) throws IOException {
// 使用字节流复制图片
FileInputStream fis = new FileInputStream("D:MegaData2022\csdn-logo-vector.png");
FileOutputStream fos = new FileOutputStream("D:\csdn-logo-vector.png");
byte[] by = new byte[1024];
int len;
while((len=fis.read(by))!=-1)
{
fos.write(by,0,len);
}
fis.close();
fos.close();
}
}
package collection;
//字节缓冲流
//BufferedOutputStream(OutputStream out)
//BufferedInputStream(InputStream in)
public class Test5 {
}
//基本字节流一次读写一个字节
//基本字节流一次读写一个字节数组
//字节缓存流一次读写一个字节
//字节缓存流一次读写一个字节数组
package collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Test1 {
public static void main(String[] args) {
List list = new ArrayList();
list.add("hello");
list.add("world");
list.add("java");
Iterator it = list.iterator();
while(it.hasNext())
{
String s = it.next();
if(s.equals("world"))
{
list.add("Java");
}
}
System.out.println(list);
}
}
//需要升序 : this需要放在前面
//需要降序 : this需要放在后面