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

Latest commit

 

History

History
History
20 lines (20 loc) · 725 Bytes

File metadata and controls

20 lines (20 loc) · 725 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package chapter15;
/* J15_03.java */
/* Writing into a Data File */
import java.io.*;
public class J15_03{
public static void main(String[] args) throws IOException {
FileWriter fws = new FileWriter("./test.txt");
System.out.println("A file named test.txt is opened for you: ");
System.out.println("Write something and Press ENTER to Save:");
FileOutputStream fos = new FileOutputStream("./test.txt");
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
String S = br.readLine(); // Reading a String
byte Buf[] = S.getBytes();
for( int i =0; i<Buf.length; i++) // While not ended
{
fos.write(Buf[i]); // Writing into file
}
fws.close();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.