簡體   English   中英

使用Java從dir命令中刪除Volume Information行

[英]Remove Volume Information lines from dir command using java

我從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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM