当前位置: 首页>>代码示例>>Java>>正文


Java Connector.openDataInputStream方法代码示例

本文整理汇总了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;
        }
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:34,代码来源:ObjectMemoryLoader.java

示例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);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:SimulatedNorFlashSectorAllocator.java

示例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;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:32,代码来源:SimulatedNorFlashSectorAllocator.java

示例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();
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:12,代码来源:SimulatedNorFlashSector.java

示例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");
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:11,代码来源:TestSystemProperties.java

示例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;
    }
}
 
开发者ID:sics-sse,项目名称:moped,代码行数:43,代码来源:ObjectMemoryLoader.java

示例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;
      }
  }
 
开发者ID:sics-sse,项目名称:moped,代码行数:44,代码来源:ObjectMemoryLoader.java


注:本文中的javax.microedition.io.Connector.openDataInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。