File tree Expand file tree Collapse file tree 4 files changed +81
-0
lines changed
Expand file tree Collapse file tree 4 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .FileInputStream ;
2+ import java .io .FileNotFoundException ;
3+ import java .io .IOException ;
4+
5+ public class FileIo {
6+ public static void main (String [] args ) {
7+ try {
8+ FileInputStream obj =new FileInputStream ("demo.txt" );
9+ int i = obj .read ();
10+ System .out .println ((char )i );
11+ } catch (Exception e ) {
12+
13+ e .printStackTrace ();
14+ }
15+ }
16+
17+
18+ }
Original file line number Diff line number Diff line change 1+ import java .io .FileInputStream ;
2+ import java .io .FileNotFoundException ;
3+
4+ public class FileIo1 {
5+ public static void main (String [] args ) {
6+ try {
7+ FileInputStream pbj =new FileInputStream ("demo.txt" );
8+ int i =0 ;
9+ while ((i =pbj .read ())!=-1 ) {
10+ System .out .print ((char )i );
11+
12+ }
13+ pbj .close ();
14+ } catch (Exception e ) {
15+
16+ e .printStackTrace ();
17+ }
18+
19+
20+
21+ }
22+
23+ }
Original file line number Diff line number Diff line change 1+ import java .io .BufferedOutputStream ;
2+ import java .io .FileNotFoundException ;
3+ import java .io .FileOutputStream ;
4+
5+ public class FileOut {
6+ public static void main (String [] args ) {
7+ try {
8+ FileOutputStream obj =new FileOutputStream ("demo.txt" );
9+ BufferedOutputStream bos =new BufferedOutputStream (obj );
10+ String s ="Saud ahmed kadapa Cdac" ;
11+ byte b []=s .getBytes ();
12+ bos .write (b );
13+ bos .flush ();
14+ bos .close ();
15+ obj .close ();
16+
17+
18+
19+
20+ } catch (Exception e ) {
21+
22+ e .printStackTrace ();
23+ }
24+
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1+ import java .util .HashMap ;
2+ import java .util .Map ;
3+
4+ public class Hashmap {
5+ public static void main (String [] args ) {
6+ Map <Integer ,String >obj =new HashMap <>();
7+ obj .put (45 , "Saud" );
8+ obj .put (55 , "Ahmed" );
9+ System .out .println (obj .containsKey (65 ));
10+ System .out .println (obj );
11+ }
12+
13+ }
You can’t perform that action at this time.
0 commit comments