Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum

Complete help forum for students preparing for icse iit aieee cbse pmt and other related exams.Stay updated about all 2011 exams.
 
HomeHome  PortalPortal  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  India NewsIndia News  
Keywords
timetable 2009 practical Icse time question SYLLABUS english sample class result 10th Exam PAPERS java CHEMISTRY Results board 2011 programs 2008 maths computer MODEL TEST table
Latest topics
» optical fibre????
Fri May 18, 2012 8:54 pm by mahnoorbloch

» physics............
Fri May 18, 2012 8:43 pm by mahnoorbloch

» magnetism...........chapter
Fri May 18, 2012 8:33 pm by mahnoorbloch

» ac generator
Fri May 18, 2012 7:46 pm by mahnoorbloch

» Great website for maths
Sun May 06, 2012 9:39 am by mahnoorbloch

» BlueJ prog
Tue Apr 24, 2012 11:53 am by arryaan

» GBTU SEE 2012 22 April
Sat Apr 21, 2012 11:17 am by shreya94

» GBTU SEE or UPTU SEE 2012 Expected cutoff marks
Sat Apr 21, 2012 11:16 am by shreya94

» GBTU SEE 2012 UPTU SEE 2012 Solutions Answer key discussion
Sat Apr 21, 2012 11:15 am by shreya94

Top posters
abhas
 
Anu..i luv icse...:)
 
G-7
 
siya
 
Candy
 
jOhNy
 
Apurva
 
WinRrule
 
ambili
 
saif
 



Search if you can't find it here

Basic File handling program in java with Output/input Stream

View previous topic View next topic Go down
AuthorMessage
abhas
Active member
Active member



PostSubject: Basic File handling program in java with Output/input Stream Sat Jun 27, 2009 4:44 pm

import java.io.*;


class fileH
{
public static void main(String args[])throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter a number of elements");
int n=Integer.parseInt(obj.readLine());

FileOutputStream fos=new FileOutputStream("Stu.dat");
DataOutputStream dos=new DataOutputStream(fos);
for(int a=0;a<n;a++)
{

System.out.println("Enter serial number");
int c=Integer.parseInt(obj.readLine());
System.out.println("Enter Name");
String N=obj.readLine();
dos.writeInt(c);
dos.writeUTF(N);

}

fos.close();
dos.close();

FileInputStream fis=new FileInputStream("Stu.dat");
DataInputStream dis=new DataInputStream(fis);
while(dis.available()!=0)
{

int d=dis.readInt();
String e=dis.readUTF();
System.out.println(d+" "+e);
}

fis.close();
dis.close();
}
}
Back to top Go down
View user profile

Basic File handling program in java with Output/input Stream

View previous topic View next topic Back to top
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Complete IIT AIEEE ICSE ISC PMT help forum :: ISC :: ISC 2010 [Class xii] :: Computer-