RIVERHEAD, N.Y. -- A Catholic priest was arraigned in his hospital room Thursday on charges he sodomized a 6-year-old Long Island boy last summer, prosecutors said.

Barry E. Ryan, who is suffering from terminal cancer, was hospitalized last week after allegedly being attacked by another inmate in the Suffolk County Jail. He had been held there on $500,000 bond since his arrest on March 4.

Ryan, 56, a resident of Palm City, Fla., since 1997, has signed a statement confessing to the sexual assault, which occurred between May and October 2003 in a private home of acquaintances on Long Island, District Attorney Thomas Spota said.

He was initially scheduled to appear before Suffolk County Court Judge Ralph Gazzillo on March 12 to answer similar charges in an indictment filed by a grand jury. But he was a no-show because he had been taken to Central Suffolk Hospital; prosecutors decided Thursday to arraign him in his hospital bed.

The indictment charged him with two counts of unlawful sexual conduct with a child and one count of endangering the welfare of a child.

The priest was alert and sitting up in bed during the brief proceeding, saying only "not guilty" to the charges, according to Robert Clifford, a spokesman for Spota. A hospital spokeswoman said Ryan, who is due in court April 19, was listed in fair condition.

Ryan's attorney, Joseph Ostrowski, did not return a call for comment.

Chief Alan Otto, a spokesman for the jail, said authorities have identified a suspect in the attack on Ryan; no arrests have been made, and the investigation is continuing. Ryan reportedly was beaten with a stick by another inmate in the shower, breaking his rib and puncturing a lung.

The priest, who told police he's suffering from terminal cancer, has not been attached to any parish or performed any priestly duties since 1995, when he was discharged from the U.S. Air Force, the district attorney said.

Ordained in 1976, Ryan enlisted as a chaplain in the Air Force in 1984. Before that he worked at parishes in the Brooklyn diocese.

The diocese notified the Suffolk district attorney about Ryan about a month ago after receiving information that the priest allegedly sodomized the youngster during recent visits to Long Island, said Deputy Inspector James Burke.

In the wake of the priest sex abuse scandal, Catholic dioceses around the country have vowed to immediately notify law enforcement officials of any allegation of sexual abuse.

The defendant, in his written confession, said he received inpatient treatment for pedophilia, depression and alcoholism this year at St. Luke's Institute, a psychiatric hospital in Silver Springs, Md., Burke said.

In recent years, Ryan worked as a media specialist in the Martin County, Fla., high school library. He was named the school's teacher of the year for 2002. He retired last October, reportedly after becoming terminally ill.