You are on page 1of 5

import java.io.

* ;
public class I0
static String fileName =
("names.txt") ;
static InputStreamReader isr =
new InputStreamReader(System.in) ;
static BufferedReader stdin = new BufferedReader (isr) s
public static void main(String[ ] args) {
try
FileWriter fw = new FileWriter (fileName)
BufferedWriter bW = new Bufferedwriter (fw)
Printwriter outFile = new PrintWriter(bw)

for(int i =0; i< 5; it+) {


")
System.out.print("Enter Name ");
String name =stdin.readLine( )
outFile.println(name)

outFile.close)5

catch(IOException e)

System.err.println(e)
import java.io.*
public class BinaryOutput
static String fileName =
"stu.dat"
static InputStreamReader isr
static BufferedReader stdin
=
new
InputStreamReader
(System.in)
new
BufferedReader (isr) ;
=

public static void main(String[ ] args) {


try {
int rno; float marks ;
FileOutputStream fw = new FileOutputStream(fileName) ;
DataoutputStream dw = new Dataoutputstream(fw);
for (int i =0 ; i<5; it+)

System.out.print("Enter Rollno: ") ;


rno Integer.parseInt (stdin.readLine( )) ;
System.out.print("Enter Marks : ");
marks Float.parseFloat(stdin.readLine( ))
= ;

dw.writeInt(rno);
dw.writeFloat (marks) ;

dw.close( )
fw.close( )

catch (IOException e)

System.err.println(e) ;
import java.io.*
import java.util.* S
class StringProcessing
static InputStreamReader input =new InputStreamReader (System. in);
statie BufferedReader keyboardInput new
= BufferedReader(input);
public static void main(String[ ] args) throws IOException
1/ Get a string
System.out.printin("Input a string") ;
String data keyboardInput.readLine(O;
=

11 Output number of characters in the line


int numberCharacters
data.length( );
System.out.println( "Number of characters ="numberCharacters "\n)
//Output tokens
for (int counter 0; counter < numberCharacters ; counter++) i{
char character =
data.charAt (counter) ;
if(character == ' )
System.out.printIn() ;
else
System.out.print(character)

System.out.println("\n") ;

You might also like