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

Appearance settings

Commit fe3fe65

Browse filesBrowse files
authored
Merge pull request codec-akash#25 from gaurav822/Write-to-A-textfile
Writing into text file in Java
2 parents df35ab6 + d2c73d8 commit fe3fe65
Copy full SHA for fe3fe65

File tree

Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Collapse file

‎WriteToTextFile.java‎

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.io.FileWriter;
2+
import java.io.IOException;
3+
4+
5+
public class WriteToTextFile {
6+
7+
public static void main(String[] args) {
8+
try {
9+
FileWriter writer = new FileWriter("myfile.txt", true);
10+
writer.write("Writing to a text file in Java");
11+
writer.write("\r\n"); // write new line
12+
writer.write("See you! Bye");
13+
writer.close();
14+
} catch (IOException e) {
15+
e.printStackTrace();
16+
}
17+
18+
}
19+
20+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.