本文整理汇总了Java中javax.microedition.io.Connector.openDataInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.openDataInputStream方法的具体用法?Java Connector.openDataInputStream怎么用?Java Connector.openDataInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.io.Connector
的用法示例。
在下文中一共展示了Connector.openDataInputStream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import javax.microedition.io.Connector; //导入方法依赖的package包/类
/**
* Loads an object memory from a given input stream. If the URI describing the source of the input
* stream corresponds to the URI of an object memory already present in the system, then that object
* memory is returned instead.
*
* @param uri a URI identifying the object memory being loaded
* @param loadIntoReadOnlyMemory specifies if the object memory should be put into read-only memory
* @return the ObjectMemoryFile instance encapsulating the loaded/resolved object memory
* @throws java.io.IOException
*/
public static ObjectMemoryFile load(String uri, boolean loadIntoReadOnlyMemory) throws IOException {
String url;
/*if[ENABLE_HOSTED]*/
if (VM.isHosted()) {
url = convertURIHosted(uri);
} else
/*end[ENABLE_HOSTED]*/
{
url = uri;
}
if (url.startsWith("file://") && filePathelements != null) {
url += ";" + filePathelements;
}
try {
DataInputStream dis = Connector.openDataInputStream(url);
ObjectMemoryFile result = load(dis, uri, loadIntoReadOnlyMemory);
dis.close();
return result;
} catch (ConnectionNotFoundException e) {
System.out.println("filePathelements=" + filePathelements);
throw e;
}
}
示例2: installSectors
import javax.microedition.io.Connector; //导入方法依赖的package包/类
/**
* Check to see if there are sectors already installed for the purpose
* specified, or If there are sectors found on file system use them as is,
* if not then setup with number of sectors and sectorSize as specified
*/
public void installSectors(int numberOfSectors, int sectorSize, int purpose) {
if (sectors.size() > 0) {
int a=1;
}
boolean foundSome = false;
final String sectorsFileExtension = SimulatedNorFlashSector.SECTORS_FILE_EXTENSION;
try {
DataInputStream fileListInput = Connector.openDataInputStream("file://./");
while (fileListInput.available() > 0) {
String fileName = fileListInput.readUTF();
if (fileName.endsWith(sectorsFileExtension)) {
foundSome = true;
SimulatedNorFlashSector memorySector = new SimulatedNorFlashSector(fileName);
releaseSector(memorySector, purpose);
}
}
fileListInput.close();
} catch (IOException e) {
throw new UnexpectedException(e);
}
if (!foundSome) {
setupSectors(numberOfSectors, sectorSize, purpose, true);
}
}
示例3: 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;
}
}
示例4: SimulatedNorFlashSector
import javax.microedition.io.Connector; //导入方法依赖的package包/类
public SimulatedNorFlashSector(String fileName) throws IOException {
this.fileName = fileName;
DataInputStream input = Connector.openDataInputStream("file://" + fileName);
Address startAddress = Address.fromPrimitive(input.readInt());
int size = input.readInt();
int purpose = input.readShort();
init(startAddress, size, purpose);
bytes = new byte[input.available()];
input.read(bytes, 0, bytes.length);
input.close();
}
示例5: main
import javax.microedition.io.Connector; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
DataInputStream propertiesStream = Connector.openDataInputStream("systemproperties:");
while (propertiesStream.available() != 0) {
System.out.println(propertiesStream.readUTF() + "=" + propertiesStream.readUTF());
}
} catch (IOException e) {
VM.print("Error systemproperties");
}
}
示例6: load
import javax.microedition.io.Connector; //导入方法依赖的package包/类
/**
* Loads an object memory from a given input stream. If the URI describing the source of the input
* stream corresponds to the URI of an object memory already present in the system, then that object
* memory is returned instead.
*
* @param uri a URI identifying the object memory being loaded
* @param loadIntoReadOnlyMemory specifies if the object memory should be put into read-only memory
* @return the ObjectMemoryFile instance encapsulating the loaded/resolved object memory
* @throws java.io.IOException
*/
public static ObjectMemoryFile load(String uri, boolean loadIntoReadOnlyMemory) throws IOException {
String url;
if (VM.isHosted()) {
url = convertURIHosted(uri);
} else {
url = uri;
}
if (url.startsWith("file://") && filePathelements != null) {
url += ";" + filePathelements;
}
try {
DataInputStream dis = null;
/* Shortcut for FRESTA plugins (loading bytecode from a hashtable instead of a file) */
if (url.startsWith("plugin://")) {
byte[] pluginData = (byte[])VM.getPluginObjectMemories().get(url);
if (pluginData != null) {
dis = new DataInputStream(new ByteArrayInputStream(pluginData));
}
}
else {
/* The original way of opening data */
dis = Connector.openDataInputStream(url);
}
ObjectMemoryFile result = load(dis, uri, loadIntoReadOnlyMemory);
dis.close();
return result;
} catch (ConnectionNotFoundException e) {
throw e;
}
}
示例7: load
import javax.microedition.io.Connector; //导入方法依赖的package包/类
/**
* Loads an object memory from a given input stream. If the URI describing the source of the input
* stream corresponds to the URI of an object memory already present in the system, then that object
* memory is returned instead.
*
* @param uri a URI identifying the object memory being loaded
* @param loadIntoReadOnlyMemory specifies if the object memory should be put into read-only memory
* @return the ObjectMemoryFile instance encapsulating the loaded/resolved object memory
* @throws java.io.IOException
*/
public static ObjectMemoryFile load(String uri, boolean loadIntoReadOnlyMemory) throws IOException {
String url;
if (VM.isHosted()) {
url = convertURIHosted(uri);
} else {
url = uri;
}
if (url.startsWith("file://") && filePathelements != null) {
url += ";" + filePathelements;
}
try {
DataInputStream dis = null;
/* Shortcut for FRESTA plugins (loading bytecode from a hashtable instead of a file) */
if (url.startsWith("plugin://")) {
byte[] pluginData = (byte[])VM.getPluginObjectMemories().get(url);
VM.println("ObjectMemoryFile: hash = " + VM.datahash(pluginData));
if (pluginData != null) {
dis = new DataInputStream(new ByteArrayInputStream(pluginData));
}
}
else {
/* The original way of opening data */
dis = Connector.openDataInputStream(url);
}
ObjectMemoryFile result = load(dis, uri, loadIntoReadOnlyMemory);
dis.close();
return result;
} catch (ConnectionNotFoundException e) {
throw e;
}
}