Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c76a381

Browse files
Added code for Module 5 Case study 2
1 parent 85cb408 commit c76a381

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎Module 5/TextFileRead.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
/**
8+
*
9+
* @author chandrikadeb
10+
*/
11+
import java.io.*;
12+
public class TextFileRead
13+
{
14+
public static void main(String[] args) {
15+
try {
16+
FileReader reader = new FileReader("Assignment.txt");
17+
int character;
18+
19+
while ((character = reader.read()) != -1) {
20+
System.out.print((char) character);
21+
}
22+
reader.close();
23+
24+
} catch (IOException e) {
25+
e.printStackTrace();
26+
}
27+
}
28+
}

‎Module 5/TextFileWrite.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
7+
/**
8+
*
9+
* @author chandrikadeb
10+
*/
11+
import java.io.*;
12+
public class TextFileWrite
13+
{
14+
public static void main(String[] args) {
15+
try {
16+
FileWriter writer = new FileWriter("AssignSoln.txt", true);
17+
writer.write("Hello World");
18+
writer.write("This is my assignment!\n"); // write new line
19+
writer.write("Good Bye!");
20+
writer.close();
21+
} catch (IOException e) {
22+
e.printStackTrace();
23+
}
24+
}
25+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /