本文整理汇总了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;
}
}