import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
class Copy{
public static void copy(String from,String to){
FileInputStream fis=null;
FileOutputStream fos=null;
try{
fis=new FileInputStream(from);
fos=new FileOutputStream(to);//文件若不存在,自动生成
byte[] b=new byte[1024];
int length;
while((length=fis.read(b))!=-1){
fos.write(b,0,length);
}
}catch (FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
try{
fos.close();
fis.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
}
class MyWriter{
private String filename;
public MyWriter(String filename){
this.filename=filename;
}
public String getFilename(){
return filename;
}
public void setFilename(String filename){
this.filename=filename;
}
public void write(){
FileOutputStream fos=null;
try{
fos=new FileOutputStream(filename);
Scanner sc=new Scanner(System.in);
String txt=null;
while(!"over".equalsIgnoreCase((txt=sc.nextLine()))){
fos.write(txt.getBytes());
fos.write("\r\n".getBytes());
}
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}finally{
try{
if(fos!=null)
fos.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
}
public class test{
public static void main(String[] args){
MyWriter mw=new MyWriter("D:\\in.txt");
mw.write();
Copy.copy("D:\\in.txt", "D:\\out.txt");
}
}
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
class Copy{
public static void copy(String from,String to){
FileInputStream fis=null;
FileOutputStream fos=null;
try{
fis=new FileInputStream(from);
fos=new FileOutputStream(to);//文件若不存在,自动生成
byte[] b=new byte[1024];
int length;
while((length=fis.read(b))!=-1){
fos.write(b,0,length);
}
}catch (FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
try{
fos.close();
fis.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
}
class MyWriter{
private String filename;
public MyWriter(String filename){
this.filename=filename;
}
public String getFilename(){
return filename;
}
public void setFilename(String filename){
this.filename=filename;
}
public void write(){
FileOutputStream fos=null;
try{
fos=new FileOutputStream(filename);
Scanner sc=new Scanner(System.in);
String txt=null;
while(!"over".equalsIgnoreCase((txt=sc.nextLine()))){
fos.write(txt.getBytes());
fos.write("\r\n".getBytes());
}
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
}finally{
try{
if(fos!=null)
fos.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
}
public class test{
public static void main(String[] args){
MyWriter mw=new MyWriter("D:\\in.txt");
mw.write();
Copy.copy("D:\\in.txt", "D:\\out.txt");
}
}










