摘要:野子電競數(shù)據(jù)官網(wǎng)改版全新登場籃球隊(duì)員獲取返回內(nèi)容這里為了方便測試我使用了一份本地文件,使用時應(yīng)替換為真實(shí)接口返回內(nèi)容
野子電競數(shù)據(jù)官網(wǎng)改版https://www.xxe.io/全新登場
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
@API: 7.籃球隊(duì)員
@Website: https://www.xxe.io/
*/
public class BasketballPlayerInfo {
public static void main(String[] args) { try { String content = getContent(); JAXBContext jaxbContext = JAXBContext.newInstance(PlayerList.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); PlayerList list = (PlayerList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes())); list.getPlayerList().forEach(System.out::println); } catch (Throwable t) { t.printStackTrace(); } } /** * 獲取API返回內(nèi)容 ** Note: 這里為了方便測試我使用了一份本地文件,使用時應(yīng)替換為真實(shí)接口返回內(nèi)容 */ private static String getContent() { try { StringBuilder builder = new StringBuilder(); List
lines = Files.readAllLines(Paths.get("./src/main/resources/BasketballPlayerInfo.xml"), StandardCharsets.UTF_8); lines.forEach(builder::append); return builder.toString(); } catch (Throwable t) { t.printStackTrace(); return ""; } } @XmlRootElement(name = "list") public static class PlayerList{ @XmlElement(name = "i") private List playerList; public List getPlayerList() { return playerList; } } public static class Player { @XmlElement(name = "id") private String id; @XmlElement(name = "Number") private String number; @XmlElement(name = "Name_F") private String nameBig; @XmlElement(name = "Name_JS") private String nameGbShort; @XmlElement(name = "Name_J") private String nameGb; @XmlElement(name = "Name_E") private String nameEn; @XmlElement(name = "TeamID") private String teamId; @XmlElement(name = "Place") private String place; @XmlElement(name = "Birthday") private String birthday; @XmlElement(name = "Tallness") private String tallness; @XmlElement(name = "Weight") private String weight; @XmlElement(name = "Photo") private String photo; @XmlElement(name = "NbaAge") private String nbaAge; @XmlElement(name = "Salary") private String salary; @Override public String toString() { return "Player{" + "id="" + id + """ + ", number="" + number + """ + ", nameBig="" + nameBig + """ + ", nameGbShort="" + nameGbShort + """ + ", nameGb="" + nameGb + """ + ", nameEn="" + nameEn + """ + ", teamId="" + teamId + """ + ", place="" + place + """ + ", birthday="" + birthday + """ + ", tallness="" + tallness + """ + ", weight="" + weight + """ + ", photo="" + photo + """ + ", nbaAge="" + nbaAge + """ + ", salary="" + salary + """ + "}"; } }
}
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/116355.html
摘要:分享籃球即時比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下即時變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測試我使用了一份本地文件,使用時應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分 分享籃球即時比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下https://www.feijing88.com/bas... package com.huaying.demo.basketball;...
摘要:分享籃球即時比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下即時變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測試我使用了一份本地文件,使用時應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分 分享籃球即時比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下https://www.feijing88.com/bas... package com.huaying.demo.basketball;...
摘要:分享籃球即時比分接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下即時變化的比分?jǐn)?shù)據(jù)獲取返回內(nèi)容這里為了方便測試我使用了一份本地文件,使用時應(yīng)替換為真實(shí)接口返回內(nèi)容返回?cái)?shù)據(jù)如下部分 分享籃球即時比分api接口調(diào)用的示例代碼,可查看在線調(diào)用文檔,需注冊下https://www.feijing88.com/bas... package com.huaying.demo.basketball;...
摘要:簡單工廠模式創(chuàng)建單一的對象示例描述工廠模式主要是為了創(chuàng)建對象實(shí)例或者類簇抽象工廠關(guān)心的是最終產(chǎn)出創(chuàng)建的對象而不關(guān)心創(chuàng)建的過程在出現(xiàn)多個類的時候每次創(chuàng)建需要找到對應(yīng)的類往往比較麻煩這時候通常使用一個函數(shù)進(jìn)行封裝來創(chuàng)建所需要的對象這樣就無需關(guān)注 簡單工廠模式(創(chuàng)建單一的對象) 示例1 描述 工廠模式主要是為了創(chuàng)建對象實(shí)例或者類簇(抽象工廠), 關(guān)心的是最終產(chǎn)出(創(chuàng)建)的對象, 而不關(guān)心創(chuàng)建...
閱讀 3264·2021-11-23 09:51
閱讀 2537·2021-09-27 13:34
閱讀 2515·2021-09-08 09:45
閱讀 704·2019-08-30 15:44
閱讀 3527·2019-08-29 12:17
閱讀 2792·2019-08-26 12:18
閱讀 2659·2019-08-26 10:10
閱讀 3115·2019-08-23 18:02