0

Hi , I need help from java programmer to translate this code?

I have basic java in my head.. yet I am struggling to understand this coding. try{ FileInputStream FIS= new FileInputStream(args[0]); // what is this ? int data = FIS.read; while(data != 1) { system.out.write(data); // what is .write and .read in this code. data = FIS.read(); /* was this line just repeat intentionally */ } // How to know what does this code do?

8th Oct 2018, 1:52 AM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar
2 Answers
+ 1
FileInputStream FIS= new FileInputStream(args[0]) it create some kind of reader to a file with name that specified in argument (args[0]). so this'll provide you an object to read a specified file. system.out.write(data) will output the data that the object read from 'FIS.read()' to console, so you can see what you try to read, data=FIS.read()' this is intentional, the read() function read the file byte by byte that's why its inside a loop
8th Oct 2018, 2:49 PM
Taste
Taste - avatar
0
Taste thanks for the last one
9th Oct 2018, 3:06 AM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar