A Massachusetts man charged with waging a relentless cyberstalking campaign against his former roommate has pleaded guilty in federal court.

Prosecutors say 25-year-old Ryan Lin pleaded guilty Wednesday to cyberstalking, distribution of child pornography, making hoax bomb threats and other offenses. Under the plea agreement, Lin will serve as least seven years in prison.

Prosecutors say Lin hacked into his roommate's online accounts, stole private photos and diary entries from her computer and sent her personal information to hundreds of others. They say he also reported fake threats to law enforcement and created fake online accounts soliciting sex in her name that caused men to show up at her home.

Lin's attorney didn't immediately respond to an email on Wednesday.