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


Java Connector.openDataOutputStream方法代碼示例

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


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

示例1: setBytes

import javax.microedition.io.Connector; //導入方法依賴的package包/類
public void setBytes(int memoryOffset, byte[] buffer, int bufferOffset, int length) {
    if (length == 0) {
        return;
    }
    if ((memoryOffset & 1) == 1) {
        throw new IndexOutOfBoundsException("offset must be even");
    }
    if ((length & 1) == 1) {
        throw new IndexOutOfBoundsException("length must be even");
    }
    ensureInBounds(memoryOffset, buffer, bufferOffset, length);
    System.arraycopy(buffer, bufferOffset, bytes, memoryOffset, length);
    if (fileName == null) {
        return;
    }
    try {
        DataOutputStream output = Connector.openDataOutputStream("file://" + fileName);
        output.writeInt(startAddress.toUWord().toInt());
        output.writeInt(size);
        output.writeShort(purpose);
        output.write(bytes);
        output.close();
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:27,代碼來源:SimulatedNorFlashSector.java

示例2: setupSectors

import javax.microedition.io.Connector; //導入方法依賴的package包/類
public void setupSectors(int numberOfSectors, int sectorSize, int purpose, boolean useFiles) {
    uninstallSectors();
    final String sectorsFileExtension = SimulatedNorFlashSector.SECTORS_FILE_EXTENSION;
    // Delete all stores first
    try {
        DataInputStream fileListInput = Connector.openDataInputStream("file://./");
        while (fileListInput.available() > 0) {
            String fileName = fileListInput.readUTF();
            if (fileName.endsWith(sectorsFileExtension)) {
                DataOutputStream fileDeleteOutput = Connector.openDataOutputStream("deletefiles://");
                fileDeleteOutput.writeUTF(fileName);
                fileDeleteOutput.close();
            }
        }
        fileListInput.close();
    } catch (IOException e) {
        throw new UnexpectedException(e);
    }
    // Create new ones
    // TODO: Want to use the next line, but compiler creates a shared temp
    // causing translation problems
    // Address address = Address.zero();
    int address = 0;
    for (int i = 0; i < numberOfSectors; i++) {
        SimulatedNorFlashSector memorySector = new SimulatedNorFlashSector(
                Address.fromPrimitive(address), sectorSize, purpose,
                useFiles);
        releaseSector(memorySector, purpose);
        address += sectorSize;
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:32,代碼來源:SimulatedNorFlashSectorAllocator.java


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