InputStream and OutputStream
Introduction
Type
Example
FileInputStream is = new FileInputStream("test.txt");
// 1024 byte = 1kb
byte [] b = new byte[1024];
// Create new File
try(FileOutputStream os = new FileOutputStream( new File("test2.txt"))){
// read the data file from the source and put it into b
while ((is.read(b)) != -1){
// Write the data b into output , and each time of the size is 1kb
os.write(b);
}
// Handle the remaining data
os.flush();
// os.close();
}
catch(IOException e){
throw e;
}References
Last updated