reset password
Author Message
yzhao52
Posts: 32
Posted 18:25 Feb 14, 2020 |

The output image file names in all three tasks are related to the input 24-bit color image file, i.e. if the 24-bit color image file name is "peppers.ppm", then Task 2's output image file name shall be "peppers-OD4.ppm". Therefore, the output file names in these tasks can't be hard coded.

Suppose the input file name is "Ducky.ppm" and is stored in one string variable named inpImgName, you may use the following statement to extract the base and extension file names:

String token[] = inpImgName.split("\\.");

Now token[0] will contain "Ducky" and token[1] will have "ppm". The only tricky part is that to split one string into tokens in Java with delimiter ".", the split method shall use "\\." instead of ".". This is because "." is treated as one wild card in Java string splitting.

Then you may simply use + operator to concatenate to the base name.

Last edited by yzhao52 at 18:26 Feb 14, 2020.