DEERFIELD, Mass. (AP) _ A 15-year-old boy who was trapped in a boxcar full of dog food for four days, but chose not to eat any of the cargo, was given six months probation Monday for breaking and entering.

The youth, who apparently hopped the freight car in western New York, did not enter a plea at his arraignment before Judge Allan McGuane of Greenfield District Court. Assistant Clerk Damase Beaudoin said the court entered an innocent plea in his behalf.

''As far as we know, he's a first offender. The charges are continued for six months, and he's on probation for that period,'' Beaudoin said. ''If it runs according to every other case, and if he's in no trouble, his probation will be terminated at that time,''

The identity of the youth, from Fredonia, N.Y., was not released by police because of juvenile court charges stemming from his unauthorized train ride.

Besides breaking and entering, he also was charged with trespassing and possession of burglary tools, police Lt. Joseph LaChance said.

A Boston & Maine railway police officer discovered the boy Saturday afternoon after the car reached the East Deerfield yard, authorities said. The boy was banging on the container car and yelling.

He was taken to Cooley Dickinson Hospital in Northampton and released into the custody of his parents Monday morning, police said.

Although surrounded by 50-pound bags of dry dog food, the boy reportedly refused to eat any of it during his four days in the boxcar.

''He said he wouldn't eat it,'' an unidentified railroad worker told The Morning Union newspaper in Springfield. ''He read all the ingredients and just wouldn't eat it.''

A railroad spokesman, Dennis Coffey, said the youth was ''apparently running away from home'' when he broke into the container in a Buffalo train yard on Tuesday.

Somehow the door locked behind him and he was trapped, Coffey said.

''He was a little bit dehydrated, but otherwise he was all right,'' Coffey said. ''He was frightened and a little hungry.''

Coffey added, ''I certainly hope he will learn a significant lesson. This sort of thing doesn't happen very often, but occasionally we have kids jumping a freight on a prank or a dare. It's a risky business, and some kids have lost an arm or a leg or a foot.''