SuperVCD管理系统 完整代码,带各种注释,可以拿这个项目入门。
} switch(opCode) { case StoneForestProtocol.OP_GET_MUSIC_CATEGORIES: opGetMusicCategories(); break; case StoneForestProtocol.OP_GET_MUSIC_RECORDINGS: opGetMusicRecordings(); break; default: System.out.println("错误代码"); } } } catch (IOException exc) { log(exc); } protected void opGetMusicCategories() { try { ArrayList categoryList = myMusicDataAccessor.getCategories(); outputToClient.writeObject(categoryList); outputToClient.flush(); log("发出 " + categoryList.size() + " 类别信息到客户端到客户端."); } catch (IOException exc) { log("发生异常: " + exc); } } protected void opGetMusicRecordings() { try { log("读取份类信息"); String category = (String) inputFromClient.readObject(); log("类别是 " + category); ArrayList recordingList = myMusicDataAccessor.getRecordings(category); outputToClient.writeObject(recordingList); outputToClient.flush(); log("发出 " + recordingList.size() + " CD信息到客户端.");