當前位置: 首頁>>代碼示例>>Java>>正文


Java NullOutputStream.write方法代碼示例

本文整理匯總了Java中org.apache.commons.io.output.NullOutputStream.write方法的典型用法代碼示例。如果您正苦於以下問題:Java NullOutputStream.write方法的具體用法?Java NullOutputStream.write怎麽用?Java NullOutputStream.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.output.NullOutputStream的用法示例。


在下文中一共展示了NullOutputStream.write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loopAllEntitiesAndProperties

import org.apache.commons.io.output.NullOutputStream; //導入方法依賴的package包/類
public void loopAllEntitiesAndProperties() throws IOException {
    NullOutputStream nullOutputStream = new NullOutputStream();
    List<Person> listOfPersons = Service.getListOfPersons(100 * 1000);
    long currentTimeMillis = System.currentTimeMillis();
    ListContainer<Person> listContainer = new ListContainer<>(
            listOfPersons);
    Collection<?> ids = listContainer.getContainerPropertyIds();
    for (int i = 0; i < listContainer.size(); i++) {
        Item item = listContainer.getItem(listOfPersons.get(i));
        for (Object propertyId : ids) {
            Property itemProperty = item.getItemProperty(propertyId);
            final Object value = itemProperty.getValue();
            nullOutputStream.write(value.toString().getBytes());
            LOG.log(Level.FINEST, "Property: %s", value);
        }
    }
    LOG.
            log(Level.INFO,
                    "Looping all properties in 100 000 Items took {0}ms",
                    (System.currentTimeMillis() - currentTimeMillis));
}
 
開發者ID:viritin,項目名稱:viritin,代碼行數:22,代碼來源:ListContainerLoopPerformanceTest.java

示例2: loopAllEntitiesAndPropertiesWithBeanItemContainer

import org.apache.commons.io.output.NullOutputStream; //導入方法依賴的package包/類
public void loopAllEntitiesAndPropertiesWithBeanItemContainer() throws IOException {
    NullOutputStream nullOutputStream = new NullOutputStream();

    List<Person> listOfPersons = Service.getListOfPersons(100 * 1000);
    long currentTimeMillis = System.currentTimeMillis();
    BeanItemContainer<Person> c = new BeanItemContainer<>(
            Person.class, listOfPersons);
    Collection<?> ids = c.getContainerPropertyIds();
    for (int i = 0; i < c.size(); i++) {
        Item item = c.getItem(listOfPersons.get(i));
        for (Object propertyId : ids) {
            Property itemProperty = item.getItemProperty(propertyId);
            final Object value = itemProperty.getValue();
            nullOutputStream.write(value.toString().getBytes());
            LOG.log(Level.FINEST, "Property: %s", value);
        }
    }
    // ~ 350ms in 1.34, MacBook Pro (Retina, Mid 2012) 2.3Gz i7
    // ~ + 3-10ms in 1.35, when changing ListContainer to use PropertyUtils instead of WrapDynaBean
    LOG.
            log(Level.INFO,
                    "BIC from core: Looping all properties in 100 000 Items took {0}ms",
                    (System.currentTimeMillis() - currentTimeMillis));
}
 
開發者ID:viritin,項目名稱:viritin,代碼行數:25,代碼來源:ListContainerLoopPerformanceTest.java


注:本文中的org.apache.commons.io.output.NullOutputStream.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。