package prac;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Prac01 {
public static void main(String[] args) throws IOException {
String s1="a.txt";
String s2="b.txt";
method1(s1,s2);
method2(s1,s2);
method3(s1,s2);
method4(s1,s2);
method5(s1,s2);
}
private static void method5(String s1,String s2) throws IOException {
BufferedReader fr=new BufferedReader(new FileReader(s1));
BufferedWriter fw = new BufferedWriter(new FileWriter(s2));
String len=null;
while((len=fr.readLine())!=null){
fw.write(len);
fw.newLine();
fw.flush();
}
fw.close();
fr.close();
}
private static void method4(String s1,String s2) throws IOException {
BufferedReader fr=new BufferedReader(new FileReader(s1));
BufferedWriter fw = new BufferedWriter(new FileWriter(s2));
char[] chs=new char[1024];
int len=0;
while((len=fr.read())!=-1){
fw.write(chs,0,len);
}
fw.close();
fr.close();
}
private static void method3(String s1,String s2) throws IOException {
BufferedReader fr=new BufferedReader(new FileReader(s1));
BufferedWriter fw = new BufferedWriter(new FileWriter(s2));
int by=0;
while((by=fr.read())!=-1){
fw.write(by);
}
fw.close();
fr.close();
}
private static void method2(String s1,String s2) throws IOException {
FileReader fr=new FileReader(s1);
FileWriter fw = new FileWriter(s2);
char[] chs=new char[1024];
int len=0;
while((len=fr.read())!=-1){
fw.write(chs,0,len);
}
fw.close();
fr.close();
}
private static void method1(String s1,String s2) throws IOException {
FileReader fr=new FileReader(s1);
FileWriter fw = new FileWriter(s2);
int by=0;
while((by=fr.read())!=-1){
fw.write(by);
}
fw.close();
fr.close();
}
}
package prac;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Prac02 {
public static void main(String[] args) throws IOException {
String s1="F:\\picture\\1.JPG";
String s2="F:\\picture\\2.jpg";
method1(s1,s2);
method2(s1, s2);
method3(s1, s2);
method4(s1, s2);
}
private static void method4(String s1, String s2) throws IOException {
BufferedInputStream fis = new BufferedInputStream(new FileInputStream(s1));
BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(s1));
byte[] chs=new byte[1024];
int len=0;
while((len=fis.read(chs))!=-1){
fos.write(chs,0,len);
}
fis.close();
fos.close();
}
private static void method3(String s1, String s2) throws IOException {
BufferedInputStream fis = new BufferedInputStream(new FileInputStream(s1));
BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(s1));
int by=0;
while((by=fis.read())!=-1){
fos.write(by);
}
fis.close();
fos.close();
}
private static void method2(String s1, String s2) throws IOException {
FileInputStream fis = new FileInputStream(s1);
FileOutputStream fos=new FileOutputStream(s2);
byte[] chs=new byte[1024];
int len=0;
while((len=fis.read(chs))!=-1){
fos.write(chs,0,len);
}
fis.close();
fos.close();
}
private static void method1(String s1, String s2) throws IOException {
FileInputStream fis = new FileInputStream(s1);
FileOutputStream fos=new FileOutputStream(s2);
int by=0;
while((by=fis.read())!=-1){
fos.write(by);
}
fis.close();
fos.close();
}
}