Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read the content of an input file and write it in output #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions java/main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.io.*;
public class Main {
public static void main(
String[] args) throws IOException
{

FileInputStream sourceStream = null;
FileOutputStream targetStream = null;

try {
sourceStream
= new FileInputStream("sourcefile.txt");
targetStream
= new FileOutputStream("targetfile.txt");

int temp;
while ((
temp = sourceStream.read())
!= -1)
targetStream.write((byte)temp);
}
finally {
if (sourceStream != null)
sourceStream.close();
if (targetStream != null)
targetStream.close();
}
}
}
3 changes: 3 additions & 0 deletions java/sourcefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Object-oriented programming is a programming paradigm based on the concept of "objects",
which can contain data and code: data in the form of fields, and code, in the form of procedures.
A feature of objects is that an object's own procedures can access and often modify the data fields of itself.