本文整理匯總了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());
}
}
示例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;
}
}