In the code below it is fairly simple to check does the line cross into the geometry or not - it's also trivial to work out the coordinate that the line crosses
I found the envelope class in Java's JTS library very handy. An envelope holds the minimal and maximal coordinates of a geometry and is also called bounding box