As long as you weren't at war with them, it would work. I sometimes do this when there is a natural chokepoint on land early in the game so I can stop their expansion and settle my land in peace. Although putting ships in a line to stop another civ sounds sort of excessive Unless it was across a natural bay that was their only access to water, there would be no way to stop all of their boats from getting across.