File tree 9 files changed +186
-0
lines changed
9 files changed +186
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .io .SequenceInputStream ;
3
+ import java .util .Scanner ;
4
+
5
+ class FileIODemo7 {
6
+ public static void main (String [] args ){
7
+ try {
8
+ FileInputStream fin1 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
9
+ FileInputStream fin2 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
10
+ SequenceInputStream bin = new SequenceInputStream (fin1 ,fin2 );
11
+ int a = 0 ;
12
+ while ((a = bin .read ())!= -1 ){
13
+ System .out .print ((char )a );
14
+ }
15
+ }catch (Exception e ){
16
+ System .err .println (e .getMessage ());
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileOutputStream ;
2
+
3
+
4
+ class FileIODemo {
5
+ public static void main (String [] args ){
6
+ try {
7
+ FileOutputStream fout = new FileOutputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO1.txt" );
8
+ fout .write (65 );
9
+ fout .close ();
10
+ System .out .println ("Success" );
11
+ }catch (Exception e ){
12
+ System .err .println (e .getMessage ());
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileOutputStream ;
2
+ import java .util .Scanner ;
3
+
4
+ class FileIODemo2 {
5
+ public static void main (String [] args ){
6
+ try {
7
+ Scanner sc = new Scanner (System .in );
8
+ FileOutputStream fout = new FileOutputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
9
+ System .out .println ("Enter a message : " );
10
+ String msg = sc .nextLine ();
11
+ byte [] arr = msg .getBytes ();
12
+ fout .write (arr );
13
+ fout .close ();
14
+ System .out .println ("Success" );
15
+ }catch (Exception e ){
16
+ System .err .println (e .getMessage ());
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .util .Scanner ;
3
+
4
+ class FileIODemo3 {
5
+ public static void main (String [] args ){
6
+ try {
7
+ FileInputStream fin = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO1.txt" );
8
+ int a = fin .read ();
9
+ System .out .println ((char )a );
10
+ System .out .println ("Success" );
11
+ }catch (Exception e ){
12
+ System .err .println (e .getMessage ());
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .util .Scanner ;
3
+
4
+ class FileIODemo4 {
5
+ public static void main (String [] args ){
6
+ try {
7
+ FileInputStream fin = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
8
+ int a = 0 ;
9
+ while ((a = fin .read ())!= -1 ){
10
+ System .err .print ((char )a );
11
+ }
12
+ System .out .println ("Success" );
13
+ }catch (Exception e ){
14
+ System .err .println (e );
15
+ }
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileOutputStream ;
2
+ import java .io .BufferedOutputStream ;
3
+ import java .util .Scanner ;
4
+
5
+ class FileIODemo5 {
6
+ public static void main (String [] args ){
7
+ try {
8
+ Scanner sc = new Scanner (System .in );
9
+ FileOutputStream fin = new FileOutputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
10
+ BufferedOutputStream buff = new BufferedOutputStream (fin );
11
+ System .out .println ("Enter a message : " );
12
+ String msg = sc .nextLine ();
13
+ byte [] arr = msg .getBytes ();
14
+ buff .write (arr );
15
+ buff .flush ();
16
+ buff .close ();
17
+ System .out .println ("Success" );
18
+ }catch (Exception e ){
19
+ System .err .println (e );
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .io .BufferedInputStream ;
3
+ import java .util .Scanner ;
4
+
5
+ class FileIODemo6 {
6
+ public static void main (String [] args ){
7
+ try {
8
+ FileInputStream fin = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
9
+ BufferedInputStream bin = new BufferedInputStream (fin );
10
+ int a = 0 ;
11
+ while ((a = bin .read ())!= -1 ){
12
+ System .out .print ((char )a );
13
+ }
14
+ System .out .println ("Success" );
15
+ }catch (Exception e ){
16
+ System .err .println (e .getMessage ());
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .io .FileOutputStream ;
3
+ import java .io .SequenceInputStream ;
4
+ import java .util .Scanner ;
5
+
6
+ class FileIODemo8 {
7
+ public static void main (String [] args ){
8
+ try {
9
+ FileInputStream fin1 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
10
+ FileInputStream fin2 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
11
+ FileOutputStream fout = new FileOutputStream ("E:\\ JAVA\\ Java Classes Programs\\ SequenceOutput.txt" );
12
+ SequenceInputStream bin = new SequenceInputStream (fin1 ,fin2 );
13
+ int a = 0 ;
14
+ while ((a = bin .read ())!= -1 ){
15
+ fout .write (a );
16
+ }
17
+ fin1 .close ();
18
+ fin2 .close ();
19
+ fout .close ();
20
+ bin .close ();
21
+ }catch (Exception e ){
22
+ System .err .println (e .getMessage ());
23
+ }
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .FileInputStream ;
2
+ import java .io .FileOutputStream ;
3
+ import java .io .SequenceInputStream ;
4
+ import java .util .*;
5
+
6
+ class FileIODemo9 {
7
+ public static void main (String [] args ){
8
+ try {
9
+ FileInputStream fin1 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
10
+ FileInputStream fin2 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
11
+ FileInputStream fin3 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO5.txt" );
12
+ FileInputStream fin4 = new FileInputStream ("E:\\ JAVA\\ Java Classes Programs\\ HelloIO.txt" );
13
+ FileOutputStream fout = new FileOutputStream ("E:\\ JAVA\\ Java Classes Programs\\ SequenceOutput2.txt" );
14
+
15
+ Vector <FileInputStream > vector = new Vector <FileInputStream >();
16
+ vector .add (fin1 );
17
+ vector .add (fin2 );
18
+ vector .add (fin3 );
19
+ vector .add (fin4 );
20
+
21
+ Enumeration <FileInputStream > enm = vector .elements ();
22
+ SequenceInputStream bin = new SequenceInputStream (enm );
23
+ int a = 0 ;
24
+ while ((a = bin .read ())!= -1 ){
25
+ fout .write (a );
26
+ }
27
+ fin1 .close ();
28
+ fin2 .close ();
29
+ fout .close ();
30
+ bin .close ();
31
+ }catch (Exception e ){
32
+ System .err .println (e .getMessage ());
33
+ }
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments