gpt4 book ai didi

java - 使用 java 从 dir 命令中删除卷信息行

转载 作者:行者123 更新时间:2023-12-01 15:45:10 25 4
gpt4 key购买 nike

我从 dir/a C:\Information\DataTransformation\externLibs\system

获得此输出
 Volume in drive C has no label.
Volume Serial Number is 1878-D614

Directory of C:\Information\DataTransformation\externLibs\system

08/23/2011 09:52 PM <DIR> .
08/23/2011 09:52 PM <DIR> ..
08/23/2011 09:52 PM 196,608 AFPtoXML_DP.dll
08/23/2011 09:52 PM 13,259 ASN1toXSDRunner.jar
08/23/2011 09:52 PM <DIR> birt
08/23/2011 09:52 PM 8,192 CM_CreateUUID.dll
08/23/2011 09:52 PM 19,456 EdifactValidation.dll
08/23/2011 09:52 PM 60,145 EDIValidator.jar
08/23/2011 09:52 PM 20,159 Excel2007ToDataXml.jar
08/23/2011 09:52 PM 217,088 ExcelToHtml.dll
08/23/2011 09:52 PM 192,512 ExcelToTxt.dll
08/23/2011 09:52 PM 541,646 ExcelToXml.jar
08/23/2011 09:52 PM 23,401 ExcelToXmlDataOnly.jar
08/23/2011 09:52 PM 10,032 ExcelToXml_03_07_10.jar
08/23/2011 09:52 PM 8,192 guid_transformer.dll
08/23/2011 09:52 PM 9,216 hebAsciiBidiKH.dll
08/23/2011 09:52 PM 40,960 hebAsciiBidiMoz.dll
08/23/2011 09:52 PM <DIR> HIPAAValidation
08/23/2011 09:52 PM 21,921 HIPAAValidation.jar
08/23/2011 09:52 PM 1,613 IBANValidator.jar
08/23/2011 09:52 PM 4,641 loader.jar
08/23/2011 09:52 PM 24,576 MSMQ.dll
08/23/2011 09:52 PM 24,576 MSMQOutput.dll
08/23/2011 09:52 PM 28,672 ODBC.dll
08/23/2011 09:52 PM 209,563 OfficeToXml.jar
08/23/2011 09:52 PM 17,408 PdfFormToXml_1_00_DP.dll
08/23/2011 09:53 PM <DIR> PDFLanguages
08/23/2011 09:52 PM 286,720 PdfToTxt2_3_02_07_DP.dll
08/23/2011 09:52 PM 409,600 PdfToTxt_2_02.dll
08/23/2011 09:52 PM 528,384 PdfToTxt_3_00_DP.dll
08/23/2011 09:52 PM 634,880 PdfToTxt_3_02_DP.dll
08/23/2011 09:52 PM <DIR> poi
08/23/2011 09:52 PM 24,576 PowerpointToHTML.dll
08/23/2011 09:52 PM 13,643 PptToXml.jar
08/23/2011 09:52 PM 1,487 Regex1_4.jar
08/23/2011 09:52 PM 29,696 RtfToTxt_DP.dll
08/23/2011 09:52 PM 217,088 WordToHtml.dll
08/23/2011 09:52 PM 188,416 WordToRtf.dll
08/23/2011 09:52 PM 188,416 WordToTxt.dll
08/23/2011 09:52 PM 305,428 WordToXml.jar
08/23/2011 09:52 PM 73,728 WpToTxt_DP.dll
08/23/2011 09:52 PM 19,456 X12EDIValidation.dll
08/23/2011 09:52 PM 927,669 xercesImpl.jar
08/23/2011 09:52 PM 115,701 xercesSamples.jar
08/23/2011 09:52 PM 123,705 xml-apis.jar
08/23/2011 09:52 PM 123,705 xmlParserAPIs.jar
08/23/2011 09:52 PM 8,786 XmlToBirtPP.jar
08/23/2011 09:52 PM 671,744 XpdfText.dll
42 File(s) 6,586,664 bytes
6 Dir(s) 15,978,725,376 bytes free

我想从输出中删除以下行

 Volume in drive C has no label.
Volume Serial Number is 1878-D614

Directory of C:\Information\DataTransformation\externLibs\system

我的代码

def externalLibrarySystem(csm,pluginOutputs)
{
String rs = (String)pluginOutputs.get("ExternalLibrarySystem")
String temp=rs

csm.externalLibrarySystem(rs)
{
"${rs}"
}
}

注意:temp具有dir输出

最佳答案

在 Java 中,您使用 Scanner 类。逐行复制到 StringBuilder。有一个 int 计数器,并且不要附加前 5 行。

String rs = (String)pluginOutputs.get("ExternalLibrarySystem");
StringBuilder sb = new StringBuilder();
Scanner sc = new Scanner(rs);
int cnt = 0;
while (sc.hasNextLine()) {
if(cnt>4){
sb.append(sc.nextLine()+System.getProperty("line.separator"));
}
cnt++;
}
String temp = sb.toString();

关于java - 使用 java 从 dir 命令中删除卷信息行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7189716/

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