import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
// The DataOutputStream stream let you write the primitives to an output source
// DataOutputStream out = DataOutputStream(OutputStream out);
// Methods
//public final void write(byte[] w, int off, int len)throws IOException
//Public final int write(byte [] b)throws IOException
//(a) public final void writeBooolean()throws IOException,
//(b) public final void writeByte()throws IOException,
//(c) public final void writeShort()throws IOException
//(d) public final void writeInt()throws IOException
//Public void flush()throws IOException
//public final void writeBytes(String s) throws IOException
//NOTES:
//Firstly we have to create file input.txt and put some text in it which are
//both in capital and small letters.
//This example reads lines given in a file input.txt and convert those lines into capital letters
//and finally copies them into another file output.txt.
public class DataOutputStreamDemoo {
public static void main(String[] args) throws IOException {
DataInputStream dIn = new DataInputStream(new FileInputStream("src/input.txt"));
DataOutputStream dOut = new DataOutputStream(new FileOutputStream("output.txt"));
String count;
while((count = dIn.readLine()) != null){
String uString = count.toUpperCase();
System.out.println(uString);
dOut.writeBytes(uString);
}
dIn.close();
dOut.close();
}
}

No comments:
Post a Comment