gpt4 book ai didi

java - 如何根据我的需要获得正确的输出?我的行文本分割逻辑不太好?

转载 作者:行者123 更新时间:2023-11-30 04:53:52 25 4
gpt4 key购买 nike

我试图从我从缓冲区读取器读取的数据中仅获取服务名称,我的数据数据是这样的,

NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:offacpid           0:off   1:off   2:on    3:on    4:on    5:on    6:offanacron         0:off   1:off   2:on    3:on    4:on    5:on    6:offapmd            0:off   1:off   2:on    3:on    4:on    5:on    6:offatd             0:off   1:off   2:off   3:on    4:on    5:on    6:offauditd          0:off   1:off   2:on    3:on    4:on    5:on    6:offautofs          0:off   1:off   2:off   3:on    4:on    5:on    6:offavahi-daemon    0:off   1:off   2:off   3:on    4:on    5:on    6:offavahi-dnsconfd  0:off   1:off   2:off   3:off   4:off   5:off   6:offbluetooth       0:off   1:off   2:on    3:on    4:on    5:on    6:offcapi            0:off   1:off   2:off   3:off   4:off   5:off   6:offconman          0:off   1:off   2:off   3:off   4:off   5:off   6:offcpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:offcrond           0:off   1:off   2:on    3:on    4:on    5:on    6:offcups            0:off   1:off   2:on    3:on    4:on    5:on    6:offdaemon.sh       0:off   1:off   2:off   3:on    4:on    5:on    6:offdc_client       0:off   1:off   2:off   3:off   4:off   5:off   6:offdc_server       0:off   1:off   2:off   3:off   4:off   5:off   6:offdnsmasq         0:off   1:off   2:off   3:off   4:off   5:off   6:offdund            0:off   1:off   2:off   3:off   4:off   5:off   6:offfirstboot       0:off   1:off   2:off   3:on    4:off   5:on    6:offgpm             0:off   1:off   2:on    3:on    4:on    5:on    6:offhaldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:offhidd            0:off   1:off   2:on    3:on    4:on    5:on    6:offhplip           0:off   1:off   2:on    3:on    4:on    5:on    6:offhttpd           0:off   1:off   2:off   3:off   4:off   5:off   6:offip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:offipmi            0:off   1:off   2:off   3:off   4:off   5:off   6:offiptables        0:off   1:off   2:on    3:on    4:on    5:on    6:offirda            0:off   1:off   2:off   3:off   4:off   5:off   6:offirqbalance      0:off   1:off   2:on    3:on    4:on    5:on    6:offiscsi           0:off   1:off   2:off   3:on    4:on    5:on    6:offiscsid          0:off   1:off   2:off   3:on    4:on    5:on    6:offisdn            0:off   1:off   2:on    3:on    4:on    5:on    6:offjexec           0:on    1:on    2:on    3:on    4:on    5:on    6:onkdump           0:off   1:off   2:off   3:off   4:off   5:off   6:offkudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:offlibvirt-guests  0:off   1:off   2:off   3:on    4:on    5:on    6:offlibvirtd        0:off   1:off   2:off   3:on    4:on    5:on    6:offlvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:offmcstrans        0:off   1:off   2:on    3:on    4:on    5:on    6:offmdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:offmdmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:offmessagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:offmicrocode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:offmultipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:offnetconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:offnetfs           0:off   1:off   2:off   3:on    4:on    5:on    6:offnetplugd        0:off   1:off   2:off   3:off   4:off   5:off   6:offnetwork         0:off   1:off   2:on    3:on    4:on    5:on    6:offnfs             0:off   1:off   2:off   3:off   4:off   5:off   6:offnfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:offnscd            0:off   1:off   2:off   3:off   4:off   5:off   6:offntpd            0:off   1:off   2:off   3:off   4:off   5:off   6:offpand            0:off   1:off   2:off   3:off   4:off   5:off   6:offpcscd           0:off   1:off   2:on    3:on    4:on    5:on    6:offportmap         0:off   1:off   2:off   3:on    4:on    5:on    6:offpsacct          0:off   1:off   2:off   3:off   4:off   5:off   6:offrawdevices      0:off   1:off   2:off   3:on    4:on    5:on    6:offrdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:offreadahead_early 0:off   1:off   2:on    3:on    4:on    5:on    6:offreadahead_later 0:off   1:off   2:off   3:off   4:off   5:on    6:offrestorecond     0:off   1:off   2:on    3:on    4:on    5:on    6:offrhnsd           0:off   1:off   2:off   3:on    4:on    5:on    6:offrhsmcertd       0:off   1:off   2:off   3:on    4:on    5:on    6:offrpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:offrpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:offrpcsvcgssd      0:off   1:off   2:off   3:off   4:off   5:off   6:offsaslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:offsendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:offsetroubleshoot  0:off   1:off   2:off   3:on    4:on    5:on    6:offsmartd          0:off   1:off   2:on    3:on    4:on    5:on    6:offsquid           0:off   1:off   2:off   3:off   4:off   5:off   6:offsshd            0:off   1:off   2:on    3:on    4:on    5:on    6:offsvnserve        0:off   1:off   2:off   3:off   4:off   5:off   6:offsyslog          0:off   1:off   2:on    3:on    4:on    5:on    6:offtux             0:off   1:off   2:off   3:off   4:off   5:off   6:offvncserver       0:off   1:off   2:off   3:off   4:off   5:off   6:offwdaemon         0:off   1:off   2:off   3:off   4:off   5:off   6:offwinbind         0:off   1:off   2:off   3:off   4:off   5:off   6:offwpa_supplicant  0:off   1:off   2:off   3:off   4:off   5:off   6:offxend            0:off   1:off   2:on    3:on    4:on    5:on    6:offxendomains      0:off   1:off   2:off   3:on    4:on    5:on    6:offxfs             0:off   1:off   2:on    3:on    4:on    5:on    6:offxinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:offypbind          0:off   1:off   2:off   3:off   4:off   5:off   6:offyum-updatesd    0:off   1:off   2:on    3:on    4:on    5:on    6:offxinetd based services:        chargen-dgram:  off        chargen-stream: off        cvs:            off        daytime-dgram:  off        daytime-stream: off        discard-dgram:  off        discard-stream: off        echo-dgram:     off        echo-stream:    off        eklogin:        off        ekrb5-telnet:   off        gssftp:         off        klogin:         off        krb5-telnet:    off        kshell:         off        rmcp:           off        rsync:          off        tcpmux-server:  off        tftp:           off        time-dgram:     off        time-stream:    off

i want to get onlt servie name from this data these all are actually services of my linux system i am using this technique,

String text = "";
while((text = in.readLine()) != null) {
text = text.split(" ")[0];
services.append(text+"\n");
System.out.print(text+"\n");
}

实际上,我正在使用缓冲区读取器“in”读取数据,即缓冲区渲染器并将其分割在空间上,但我从这段代码中得到了这个结果,

linuxNetworkManageracpidanacronapmdatdauditdautofsavahi-daemonavahi-dnsconfdbluetoothcapiconmancpuspeedcrondcupsdaemon.shdc_clientdc_serverdnsmasqdundfirstbootgpmhaldaemonhiddhpliphttpdip6tablesipmiiptablesirdairqbalanceiscsiiscsidisdnjexeckdumpkudzulibvirt-guestslibvirtdlvm2-monitormcstransmdmonitormdmpdmessagebusmicrocode_ctlmultipathdnetconsolenetfsnetplugdnetworknfsnfslocknscdntpdpandpcscdportmappsacctrawdevicesrdiscreadahead_early 0:off   1:off   2:on    3:on    4:on    5:on    6:offreadahead_later 0:off   1:off   2:off   3:off   4:off   5:on    6:offrestorecondrhnsdrhsmcertdrpcgssdrpcidmapdrpcsvcgssdsaslauthdsendmailsetroubleshootsmartdsquidsshdsvnservesyslogtuxvncserverwdaemonwinbindwpa_supplicantxendxendomainsxfsxinetdypbindyum-updatesdxinetd    chargen-dgram:    chargen-stream: off    cvs:    daytime-dgram:    daytime-stream: off    discard-dgram:    discard-stream: off    echo-dgram:    echo-stream:    eklogin:    ekrb5-telnet:    gssftp:    klogin:    krb5-telnet:    kshell:    rmcp:    rsync:    tcpmux-server:    tftp:    time-dgram:    time-stream:

why is there some service state also comming with the service name like

 "readahead_early   0:off   1:off   2:on    3:on    4:on    5:on    6:off"
"chargen-stream: off"

我只想获取所有这些服务名称

最佳答案

也许您的来源混合了制表符和空格?确保整个过程中都使用空格,或者执行 text.split("\\s+")

关于java - 如何根据我的需要获得正确的输出?我的行文本分割逻辑不太好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9188805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com