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


Java ConnectionNotFoundException类代码示例

本文整理汇总了Java中javax.microedition.io.ConnectionNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java ConnectionNotFoundException类的具体用法?Java ConnectionNotFoundException怎么用?Java ConnectionNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionNotFoundException类属于javax.microedition.io包,在下文中一共展示了ConnectionNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的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: open

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
/**
 * Sets up the state of the connection, but
 * does not actually connect to the server until there's something
 * to do.
 *
 * @param theUrl           URL object
 * @param mode             The access mode, ignored
 *                         timeout exceptions, ignored
 *
 * @return reference to this connection
 *
 * @exception IllegalArgumentException If a parameter is invalid.
 * @exception ConnectionNotFoundException If the connection cannot be
 *             found.
 * @exception IOException  If some other kind of I/O error occurs.
 */
private Connection open(HttpUrl theUrl, int mode)
    throws IOException, IllegalArgumentException,
    ConnectionNotFoundException {

    url = theUrl;

    initStreamConnection(mode);

    if (url.port == -1) {
        url.port = default_port;
    }

    if (url.host == null) {
        throw new IllegalArgumentException("missing host in URL");
    }

    hostAndPort = url.host + ":" + url.port;

    return this;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:37,代码来源:Protocol.java

示例3: createLinkItem

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
/**
 * Create a Link item to be shown as the topmost item in the view.
 *
 * Tapping on the link will prompt to open the link URL in the
 * platform browser.
 *
 * @return Link item
 */
private LinkItem createLinkItem() {
    // A listener to invoke whenever the link gets selected; either by
    // direct touch selection or by the selection command
    final LinkSelectionListener selectionListener = new LinkSelectionListener() {
        public void linkSelected(LinkThing link) {
            try {
                Main.getInstance().platformRequest(link.getUrl());
            }
            catch (ConnectionNotFoundException ex) {
                System.out.println("Connection not found: " + ex.getMessage());
            }
        }
    };
    linkItem = new LinkItem(link, getWidth(), true, selectionListener, null, this);

    return linkItem;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:CommentsView.java

示例4: execute

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void execute(String url) {
    try {
        mid.platformRequest(url);
    } catch (ConnectionNotFoundException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:11,代码来源:GameCanvasImplementation.java

示例5: attemptCallout

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void attemptCallout(String number) {
    try {
        String scrubbed = "";
        String valid = "01234567890+#*";
        for(int i = 0; i < number.length() ; ++i) {
            if(valid.indexOf(number.charAt(i)) != -1) {
                scrubbed += number.charAt(i);
            }
        }
        CommCareContext._().getMidlet().platformRequest("tel:" + scrubbed);
    } catch (ConnectionNotFoundException e) {
        Logger.exception("calling : " + number,e);
        J2MEDisplay.showError("Error", "Connection not found: " + e.getMessage());
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:16,代码来源:CommCareEntitySelectController.java

示例6: playAudio

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void playAudio() throws AudioException, FileException
{
    errorItem.setLabel("");
    errorItem.setText("");
    System.err.println("Attempting to play audio...");
    messageItem.setText("Starting the Player...");

    recordService.startPlayback();

    try
    {
        if(recMid!= null)
            recMid.platformRequest(fullName);
        else
            throw new ConnectionNotFoundException("Since midlet is null, try 2nd method of playback");
    }
    catch(ConnectionNotFoundException cnfe)
    {
        cnfe.printStackTrace();
        /*If the platform request fails, which it shouldn't, attempt to start playback
         * through the service.*/
          recordService.startPlayback();
    }

    System.err.println("Player has started.");
    messageItem.setText("Player has started!");

    form.removeCommand(eraseCommand);
    form.removeCommand(saveCommand);
    form.removeCommand(playCommand); //"Hide" playCommand when playing has started
    form.removeCommand(recordCommand); //"Hide" recordCommand when playing has started
    form.addCommand(stopCommand); //Show recordCommand when playing has started

    //Thread.currentThread().sleep(FOREVER);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:36,代码来源:AudioCaptureState.java

示例7: processView

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
private void processView(String file) {
    try {
        System.out.println("Opening: " + file);
        midlet.platformRequest(file);
    } catch (ConnectionNotFoundException e) {
        System.out.println("Error displaying image: " + e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:10,代码来源:ImageChooserState.java

示例8: registerConnection

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
/**
 * Called when registration is established.
 * @param midletSuite MIDlet suite for the suite registering,
 *                   the suite only has to implement isRegistered,
 *                   checkForPermission, and getID.
 * @param connection generic connection <em>protocol</em>, <em>host</em>
 *               and <em>port number</em>
 *               (optional parameters may be included
 *               separated with semi-colons (;))
 * @param midlet  class name of the <code>MIDlet</code> to be launched,
 *               when new external data is available
 * @param filter a connection URL string indicating which senders
 *               are allowed to cause the MIDlet to be launched
 * @exception  IllegalArgumentException if the connection string is not
 *               valid
 * @exception IOException if the connection is already
 *              registered or if there are insufficient resources
 *              to handle the registration request
 * @exception ClassNotFoundException if the <code>MIDlet</code> class
 *               name can not be found in the current
 *               <code>MIDlet</code> suite
 */
public void registerConnection(MIDletSuite midletSuite, String connection, 
    String midlet, String filter) 
    throws IllegalArgumentException, IOException, ClassNotFoundException {

    checkIsNotHost(connection, true);

    /*
     * Attempt to open the connection to perform security check
     * int the context of the current MIDlet suite.
     */
    try {
        Class.forName(
            "com.sun.midp.io.j2me.serversocket.Socket");
    } catch (ClassNotFoundException e) {
        throw new ConnectionNotFoundException(
            "Connection not supported");
    }

    try {
        midletSuite.checkForPermission("javax.microedition.io.Connector.serversocket",
                                        connection);
    } catch (InterruptedException ie) {
        throw new InterruptedIOException(
            "Interrupted while trying to ask the user permission");
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:49,代码来源:ProtocolPushImpl.java

示例9: checkIsNotHost

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
/**
 * Check if host is not present.
 * @param connection generic connection <em>protocol</em>, <em>host</em>
 *               and <em>port number</em>
 *               (optional parameters may be included
 *               separated with semi-colons (;))
 * @param checkPort check if the port is not omitted
 * @exception  IllegalArgumentException if the connection contains no port
 *               value
 * @exception ConnectionNotFoundException if connection contains any host
 *               name
 */
protected void checkIsNotHost(String connection, boolean checkPort) 
    throws IllegalArgumentException, ConnectionNotFoundException {
    HttpUrl url = new HttpUrl(connection);
    // Server connections do not have a host
    if (url.host != null) {
        throw new ConnectionNotFoundException(
            "Connection not supported");
    }

    if (checkPort && url.port == -1) {
        throw new IllegalArgumentException("Port missing");
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:ProtocolPush.java

示例10: startApp

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void startApp() {
    try {
        platformRequest("http://localhost:8000/tests/Manifest1Updated.jad");
    } catch (ConnectionNotFoundException e) {
        e.printStackTrace();
        System.out.println("FAIL");
    }
    Isolate.currentIsolate().exit(0);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:10,代码来源:AMIDletUpdater.java

示例11: startApp

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void startApp() {
    try {
        platformRequest("http://localhost:8000/tests/test.html");
    } catch (ConnectionNotFoundException e) {
        e.printStackTrace();
        System.out.println("FAIL");
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:9,代码来源:TestMIDletPeer.java

示例12: test

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void test(TestHarness th) {
    try {
        MIDletPeer midletPeer = new MIDletPeer();

        midletPeer.platformRequest("x-contacts:add?number=3393333333");
        th.check(hasNumber());
        th.check(getNumber(), "3393333333");

        midletPeer.platformRequest("x-contacts:add?");
        th.check(!hasNumber());
    } catch (ConnectionNotFoundException e) {
        th.fail("Unexpected exception: " + e);
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:15,代码来源:AddContactTest.java

示例13: load

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的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

示例14: load

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的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

示例15: openUrl

import javax.microedition.io.ConnectionNotFoundException; //导入依赖的package包/类
public void openUrl(String url) {
        try {
            boolean flag = this.platformRequest(url);
            
            if (flag) {
                shutdown();
            }
        } catch (ConnectionNotFoundException ex) {
            //#debug
//#             ex.printStackTrace();
        }
    }
 
开发者ID:queader,项目名称:Comcraft,代码行数:13,代码来源:ComcraftMIDlet.java


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