This paper studies optimal reinsurance and investment strategies that maximize expected utility of the terminal wealth for an insurer in a stochastic market. The insurer's preference is represented by a two-piece utility function which can be regarded as a generalization of traditional concave utility functions. We employ martingale approach and convex optimization method to transform the dynamic maximization problem into an equivalent static optimization problem. By solving the optimization problem, we derive explicit expressions of the optimal reinsurance and investment strategy and the optimal wealth process.2010 Mathematics Subject Classification. Primary: 58F15, 58F17; Secondary: 53C35.