forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintwriter.java
More file actions
49 lines (41 loc) · 1.17 KB
/
Printwriter.java
File metadata and controls
49 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package file;
import java.io.File;
import java.io.FileNotFoundException;
//import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Printwriter {
/**
* @param args
* @throws Exception
* @throws FileNotFoundException
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File f = new File("D:/DEEP/fifth.txt");
f.createNewFile();
PrintWriter pw = new PrintWriter(f);
Scanner s = new Scanner(System.in);
System.out.println("Enter your HOME ADDRESS: ");
String s1 = s.nextLine();
String s2 = s.nextLine();
String s3 = s.nextLine();
String s4 = s.nextLine();
s.close();
pw.write(s1 + " ," + " ");
pw.write(s2 + " ," + " ");
pw.write(s3 + " ," + " ");
pw.write(s4);
pw.flush();
pw.close();
System.out.println("\n" + "\"" + s1 + "\"" + "\n" + s2 + "\n" + s3 + "\n" + s4);
/*
* PrintWriter pw1 = new PrintWriter(System.out); int a; int sum = 0; do{
* pw1.write("Enter a positive number= "); a = s.nextInt(); sum = sum + a;
*
* }while(a != 0);
*
* pw1.write("Addition of entered number is= "+sum); pw1.flush(); pw1.close();
*/
}
}