SlideShare a Scribd company logo
Program to copy content of one file to another
existing file
import java.io.*;
public class jonitafilecopy {
public static void main(String[] args)
{

try
{
FileReader fr = new FileReader("pqr.txt");
FileWriter fw = new FileWriter("x.txt");
int k;
while( ( k = fr.read() ) != -1 )
{
fw.write(k);
System.out.print((char) k);
}
fw.close();
fr.close();
}
catch(FileNotFoundException e)
{
System.out.println("File does not exist. " + e);
}
catch(IOException e)
{
System.out.println("Some I/O problem. " + e);
}
}

More Related Content

What's hot (20)

PPTX
working with files
SangeethaSasi1
 
PDF
I/O in java Part 1
ashishspace
 
PPTX
Xitrum internals
Ngoc Dao
 
PPT
Java File I/O
Canterbury HS
 
DOCX
source code which create file and write into it
melakusisay507
 
PPTX
Java file
sonnetdp
 
PPT
17 files and streams
Docent Education
 
PDF
Python - Lecture 9
Ravi Kiran Khareedi
 
PDF
C++ prgms io file unit 7
Ananda Kumar HN
 
PPT
Java Input Output and File Handling
Sunil OS
 
PPTX
Progress Report090806
GUANBO
 
PPT
Oop lecture9 11
Shahriar Robbani
 
PDF
Long Tail Treasure Trove
Gianugo Rabellino
 
PPTX
Progress Report090806
GUANBO
 
PPT
file handling, dynamic memory allocation
indra Kishor
 
TXT
Codigo java
weberson2012
 
PPTX
RandomAccessFile Quick Start
Guo Albert
 
PDF
Python - File operations & Data parsing
Felix Z. Hoffmann
 
PPTX
Java
Dhruv Sabalpara
 
PPTX
ATS Internals
Chao Xu
 
working with files
SangeethaSasi1
 
I/O in java Part 1
ashishspace
 
Xitrum internals
Ngoc Dao
 
Java File I/O
Canterbury HS
 
source code which create file and write into it
melakusisay507
 
Java file
sonnetdp
 
17 files and streams
Docent Education
 
Python - Lecture 9
Ravi Kiran Khareedi
 
C++ prgms io file unit 7
Ananda Kumar HN
 
Java Input Output and File Handling
Sunil OS
 
Progress Report090806
GUANBO
 
Oop lecture9 11
Shahriar Robbani
 
Long Tail Treasure Trove
Gianugo Rabellino
 
Progress Report090806
GUANBO
 
file handling, dynamic memory allocation
indra Kishor
 
Codigo java
weberson2012
 
RandomAccessFile Quick Start
Guo Albert
 
Python - File operations & Data parsing
Felix Z. Hoffmann
 
ATS Internals
Chao Xu
 

Viewers also liked (20)

PDF
Perl IO
guest998254
 
PPT
Iostreams
aptechsravan
 
PDF
Servlet Event framework
AshishSingh Bhatia
 
PDF
Java I/O Part 2
AshishSingh Bhatia
 
PPTX
2CPP17 - File IO
Michael Heron
 
PPS
Files & IO in Java
CIB Egypt
 
PPT
Chapter 6 Java IO File
Khirulnizam Abd Rahman
 
PPT
Chapter 5 Class File
Khirulnizam Abd Rahman
 
PDF
JRuby: Pushing the Java Platform Further
Charles Nutter
 
PPTX
Featuring JDK 7 Nio 2
Orange and Bronze Software Labs
 
PPTX
Java Tutorial Lab 6
Berk Soysal
 
PDF
Java IO
UTSAB NEUPANE
 
PPT
File io
Pri Dhaka
 
PPTX
Reading and writting
andreeamolnar
 
PPT
Various io stream classes .47
myrajendra
 
PDF
I/O In Java Part 2
ashishspace
 
PDF
Xlab #1: Advantages of functional programming in Java 8
XSolve
 
PPTX
Java Input Output (java.io.*)
Om Ganesh
 
PDF
Java Course 8: I/O, Files and Streams
Anton Keks
 
PPT
Java IO Package and Streams
babak danyal
 
Perl IO
guest998254
 
Iostreams
aptechsravan
 
Servlet Event framework
AshishSingh Bhatia
 
Java I/O Part 2
AshishSingh Bhatia
 
2CPP17 - File IO
Michael Heron
 
Files & IO in Java
CIB Egypt
 
Chapter 6 Java IO File
Khirulnizam Abd Rahman
 
Chapter 5 Class File
Khirulnizam Abd Rahman
 
JRuby: Pushing the Java Platform Further
Charles Nutter
 
Featuring JDK 7 Nio 2
Orange and Bronze Software Labs
 
Java Tutorial Lab 6
Berk Soysal
 
Java IO
UTSAB NEUPANE
 
File io
Pri Dhaka
 
Reading and writting
andreeamolnar
 
Various io stream classes .47
myrajendra
 
I/O In Java Part 2
ashishspace
 
Xlab #1: Advantages of functional programming in Java 8
XSolve
 
Java Input Output (java.io.*)
Om Ganesh
 
Java Course 8: I/O, Files and Streams
Anton Keks
 
Java IO Package and Streams
babak danyal
 
Ad

Recently uploaded (20)

PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
July Patch Tuesday
Ivanti
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
July Patch Tuesday
Ivanti
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ad

java copy file program

  • 1. Program to copy content of one file to another existing file import java.io.*; public class jonitafilecopy { public static void main(String[] args) { try { FileReader fr = new FileReader("pqr.txt"); FileWriter fw = new FileWriter("x.txt"); int k; while( ( k = fr.read() ) != -1 ) { fw.write(k); System.out.print((char) k); } fw.close(); fr.close(); } catch(FileNotFoundException e) { System.out.println("File does not exist. " + e); } catch(IOException e) { System.out.println("Some I/O problem. " + e); } }