Guys can you help me with the following detail.
Why does the following example work.
I dont get my head around the following line:
" int data = inputStream.read(); "
get the bytes of the file c:/data.txt concetinated automatically in the vaiable data or
does inputStream.read() read the file c:/data.txt all at once?
best regards Fabian
public static void main(String[] args) throws Exception
{
//Create a stream to read bytes from a file
FileInputStream inputStream = new FileInputStream("c:/data.txt");
//Create a stream to write bytes to a file
FileOutputStream outputStream = new FileOutputStream("c:/result.txt");
while (inputStream.available() > 0) //as long as there are unread bytes
{
int data = inputStream.read(); // Read the next byte into the data variable
outputStream.write(data); // and write it to the second stream
}
inputStream.close(); //Close both streams. We don't need them any more.
outputStream.close();
}