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


C# String.startsWith方法代码示例

本文整理汇总了C#中System.String.startsWith方法的典型用法代码示例。如果您正苦于以下问题:C# String.startsWith方法的具体用法?C# String.startsWith怎么用?C# String.startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.startsWith方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getRelativePath

        static public String getRelativePath(String path1, String path2)
        {
            if (!path1.startsWith(path2))
                return path1;

            return path1.substring(path2.length());
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:7,代码来源:RhoFilePath.cs

示例2: nodeExists

 public override bool nodeExists(String name)
 {
     //throws BackingStoreException {
     if (null == name) {
     throw new java.lang.NullPointerException();
     }
     AbstractPreferences startNode = null;
     lock (lockJ) {
     if (isRemoved()) {
         if ("".equals(name)) { //$NON-NLS-1$
             return false;
         }
         // prefs.9=This node has been removed
             throw new java.lang.IllegalStateException("This node has been removed"); //$NON-NLS-1$
     }
     validateName(name);
     if ("".equals(name) || "/".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
         return true;
     }
     if (name.startsWith("/")) { //$NON-NLS-1$
         startNode = root;
         name = name.substring(1);
     } else {
         startNode = this;
     }
     }
     try {
     Preferences result = startNode.nodeImpl(name, false);
     return null == result ? false : true;
     } catch (java.lang.IllegalArgumentException e) {
     return false;
     }
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:33,代码来源:AbstractPreferences.cs

示例3: node

 public override Preferences node(String name)
 {
     AbstractPreferences startNode = null;
     lock (lockJ) {
     checkState();
     validateName(name);
     if ("".equals(name)) { //$NON-NLS-1$
         return this;
     } else if ("/".equals(name)) { //$NON-NLS-1$
         return root;
     }
     if (name.startsWith("/")) { //$NON-NLS-1$
         startNode = root;
         name = name.substring(1);
     } else {
         startNode = this;
     }
     }
     try {
     return startNode.nodeImpl(name, true);
     } catch (BackingStoreException e) {
     // should not happen
     return null;
     }
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:25,代码来源:AbstractPreferences.cs

示例4: processToolBarCommand

        private void processToolBarCommand(object sender, EventArgs e,  String strAction)
        {

            boolean callback = false;
            if (strAction == "back")
            {
                if (m_strAppBackUrl.length() > 0)
                    processToolBarCommand(this, e, m_strAppBackUrl);
                else if (m_backHistory.Count > 0)
                {
                    Uri destination = m_backHistory.Peek();
                    m_webBrowser.Navigate(destination);
                }
                return;
            }

            if (strAction.startsWith("callback:"))
            {
                strAction = strAction.substring(9);
                callback = true;
            }

            if (strAction == "forward" && m_forwardHistory.Count > 0)
            {
                Uri destination = m_forwardHistory.Peek();
                m_webBrowser.Navigate(destination);
                return;
            }

            if (strAction == "home")
            {
                String strHomePage = RhoRuby.getStartPage();
                strHomePage = canonicalizeRhoUrl(strHomePage);
                m_webBrowser.Navigate(new Uri(strHomePage));
                return;
            }

            if (strAction == "log")
            {
                showLogScreen();
                return;
            }

            if (strAction == "options")
            {
                String curUrl = RhoRuby.getOptionsPage();
				curUrl = canonicalizeRhoUrl(curUrl);
			    m_webBrowser.Navigate(new Uri(curUrl));
                return;
            }

            if (strAction == "refresh" && m_currentUri != null)
            {
                m_webBrowser.Navigate(m_currentUri);
                return;
            }

            if (strAction == "sync")
            {
                SyncThread.doSyncAllSources(true);
                return;
            }

            strAction = canonicalizeRhoUrl(strAction);
            if (callback)
            {
                RhoClassFactory.createNetRequest().pushData(strAction, "rho_callback=1", null);
            }
            else
                m_webBrowser.Navigate(new Uri(strAction));
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:71,代码来源:RhodesApp.cs

示例5: resolveDBFilesPath

        public String resolveDBFilesPath(String strFilePath)
        {
            if (strFilePath.length() == 0 || strFilePath.startsWith(getRhoRootPath()))
                return strFilePath;

            return CFilePath.join(getRhoRootPath(), strFilePath);
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:7,代码来源:RhodesApp.cs

示例6: isRhodesAppUrl

 public boolean isRhodesAppUrl(String url)
 {
     return url.startsWith(getHomeUrl());
 }
开发者ID:rrmartins,项目名称:rhodes,代码行数:4,代码来源:RhodesApp.cs

示例7: isExternalUrl

 boolean isExternalUrl(String strUrl)
 {
     return strUrl.startsWith("http://") || strUrl.startsWith("https://") ||
         strUrl.startsWith("javascript:") || strUrl.startsWith("mailto:")
          || strUrl.startsWith("tel:") || strUrl.startsWith("wtai:") ||
          strUrl.startsWith("sms:");
 }
开发者ID:rrmartins,项目名称:rhodes,代码行数:7,代码来源:RhodesApp.cs

示例8: valueOf

        /**
         * <p><code>QName</code> derived from parsing the formatted
         * <code>String</code>.</p>
         *
         * <p>If the <code>String</code> is <code>null</code> or does not conform to
         * {@link #toString() QName.toString()} formatting, an
         * <code>IllegalArgumentException</code> is thrown.</p>
         *
         * <p><em>The <code>String</code> <strong>MUST</strong> be in the
         * form returned by {@link #toString() QName.toString()}.</em></p>

         * <p>The commonly accepted way of representing a <code>QName</code>
         * as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a>
         * by James Clark.  Although this is not a <em>standard</em>
         * specification, it is in common use,  e.g. {@link javax.xml.transform.Transformer#setParameter(String name, Object value)}.
         * This implementation parses a <code>String</code> formatted
         * as: "{" + Namespace URI + "}" + local part.  If the Namespace
         * URI <code>.equals(XMLConstants.NULL_NS_URI)</code>, only the
         * local part should be provided.</p>
         *
         * <p>The prefix value <strong><em>CANNOT</em></strong> be
         * represented in the <code>String</code> and will be set to
         * {@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX
         * XMLConstants.DEFAULT_NS_PREFIX}.</p>
         *
         * <p>This method does not do full validation of the resulting
         * <code>QName</code>.
         * <p>The Namespace URI is not validated as a
         * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
         * The local part is not validated as a
         * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
         * as specified in
         * <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.</p>
         *
         * @param qNameAsString <code>String</code> representation
         * of the <code>QName</code>
         * @return <code>QName</code> corresponding to the given <code>String</code>
         * @see #toString() QName.toString()
         */
        public static QName valueOf(String qNameAsString)
        {
            // null is not valid
            if (qNameAsString == null)
            {
                throw new java.lang.IllegalArgumentException("cannot create QName from \"null\" or \"\" String");
            }

            // "" local part is valid to preserve compatible behavior with QName 1.0
            if (qNameAsString.length() == 0)
            {
                return new QName(
                    XMLConstants.NULL_NS_URI,
                    qNameAsString,
                    XMLConstants.DEFAULT_NS_PREFIX);
            }

            // local part only?
            if (qNameAsString.charAt(0) != '{')
            {
                return new QName(
                    XMLConstants.NULL_NS_URI,
                    qNameAsString,
                    XMLConstants.DEFAULT_NS_PREFIX);
            }

            // Namespace URI improperly specified?
            if (qNameAsString.startsWith("{" + XMLConstants.NULL_NS_URI + "}"))
            {
                throw new java.lang.IllegalArgumentException(
                    "Namespace URI .equals(XMLConstants.NULL_NS_URI), "
                    + ".equals(\"" + XMLConstants.NULL_NS_URI + "\"), "
                    + "only the local part, "
                    + "\"" + qNameAsString.substring(2 + XMLConstants.NULL_NS_URI.length()) + "\", "
                    + "should be provided.");
            }

            // Namespace URI and local part specified
            int endOfNamespaceURI = qNameAsString.indexOf('}');
            if (endOfNamespaceURI == -1)
            {
                throw new java.lang.IllegalArgumentException(
                    "cannot create QName from \""
                        + qNameAsString
                        + "\", missing closing \"}\"");
            }
            return new QName(
                qNameAsString.substring(1, endOfNamespaceURI),
                qNameAsString.substring(endOfNamespaceURI + 1),
                XMLConstants.DEFAULT_NS_PREFIX);
        }
开发者ID:sailesh341,项目名称:JavApi,代码行数:90,代码来源:QName.cs

示例9: pullFile

	    public NetResponse pullFile( String strUrl, String strFileName, IRhoSession oSession, Hashtable<String, String> headers )
	    {
		    NetResponse resp = null;
            m_isPullFile = true;

		    m_bCancel = false;
    	
		    try{

	            if (!strFileName.startsWith("file:")) { 
            	    try{
	            	    strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName);
            	    } catch (IOException e) { 
                 	    LOG.ERROR("getDirPath failed.", e);
                    }              	
	            }

                m_pulledFile = RhoClassFactory.createFile();
                m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite);
                m_pulledFile.setPosTo(m_pulledFile.size());
			
			    do{
                    resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size());
			    }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0);
			
		    }finally{
                if (m_pulledFile != null)
			    {
                    try { m_pulledFile.close(); }
                    catch (IOException e)
                    {
                        LOG.ERROR("file closing failed.", e);
                    }
                    m_pulledFile = null;
			    }
		    }
		
		    copyHashtable(m_OutHeaders, headers);

            m_isPullFile = false;
            m_nCurDownloadSize = 0;
            return resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError));
	    }
开发者ID:raulvejar,项目名称:rhodes,代码行数:43,代码来源:NetRequest.cs

示例10: parseURL

        /**
         * Parses the clear text URL in {@code str} into a URL object. URL strings
         * generally have the following format:
         * <p/>
         * http://www.company.com/java/file1.java#reference
         * <p/>
         * The string is parsed in HTTP format. If the protocol has a different URL
         * format this method must be overridden.
         *
         * @param u
         *            the URL to fill in the parsed clear text URL parts.
         * @param str
         *            the URL string that is to be parsed.
         * @param start
         *            the string position from where to begin parsing.
         * @param end
         *            the string position to stop parsing.
         * @see #toExternalForm
         * @see URL
         */
        protected internal void parseURL(URL u, String str, int start, int end)
        {
            if (end < start || end < 0) {
            // Checks to ensure string index exception ahead of
            // security exception for compatibility.
            if (end <= java.lang.Integer.MIN_VALUE + 1 && (start >= str.length() || start < 0)
                    || str.startsWith("//", start) && str.indexOf('/', start + 2) == -1) { //$NON-NLS-1$
                throw new java.lang.StringIndexOutOfBoundsException(end);
            }
            if (this != u.strmHandler) {
                throw new java.lang.SecurityException();
            }
            return;
            }
            String parseString = str.substring(start, end);
            end -= start;
            int fileIdx = 0;

            // Default is to use info from context
            String host = u.getHost();
            int port = u.getPort();
            String refJ = u.getRef();
            String file = u.getPath();
            String query = u.getQuery();
            String authority = u.getAuthority();
            String userInfo = u.getUserInfo();

            int refIdx = parseString.indexOf('#', 0);
            if (parseString.startsWith("//") && !parseString.startsWith("////")) { //$NON-NLS-1$
            int hostIdx = 2, portIdx = -1;
            port = -1;
            fileIdx = parseString.indexOf('/', hostIdx);
            int questionMarkIndex = parseString.indexOf('?', hostIdx);
            if ((questionMarkIndex != -1)
                    && ((fileIdx == -1) || (fileIdx > questionMarkIndex))) {
                fileIdx = questionMarkIndex;
            }
            if (fileIdx == -1) {
                fileIdx = end;
                // Use default
                file = ""; //$NON-NLS-1$
            }
            int hostEnd = fileIdx;
            if (refIdx != -1 && refIdx < fileIdx) {
                hostEnd = refIdx;
            }
            int userIdx = parseString.lastIndexOf('@', hostEnd);
            authority = parseString.substring(hostIdx, hostEnd);
            if (userIdx > -1) {
                userInfo = parseString.substring(hostIdx, userIdx);
                hostIdx = userIdx + 1;
            }

            portIdx = parseString.indexOf(':', userIdx == -1 ? hostIdx
                    : userIdx);
            int endOfIPv6Addr = parseString.indexOf(']');
            // if there are square braces, ie. IPv6 address, use last ':'
            if (endOfIPv6Addr != -1) {
                try {
                    if (parseString.length() > endOfIPv6Addr + 1) {
                        char c = parseString.charAt(endOfIPv6Addr + 1);
                        if (c == ':') {
                            portIdx = endOfIPv6Addr + 1;
                        } else {
                            portIdx = -1;
                        }
                    } else {
                        portIdx = -1;
                    }
                } catch (Exception e) {
                    // Ignored
                }
            }

            if (portIdx == -1 || portIdx > fileIdx) {
                host = parseString.substring(hostIdx, hostEnd);
            } else {
                host = parseString.substring(hostIdx, portIdx);
                String portString = parseString.substring(portIdx + 1, hostEnd);
                if (portString.length() == 0) {
//.........这里部分代码省略.........
开发者ID:sailesh341,项目名称:JavApi,代码行数:101,代码来源:URLStreamHandler.cs

示例11: getResource

 public java.net.URL getResource(String name)
 {
     String root = "";
     if (name.startsWith("/"))
     {
         name = name.substring(1);
     }
     else
     {
         String package = this.getClass().getPackage().getName();
         root = package.replace('.', '/') + '/';
     }
     name = root + name;
     return getClassLoader().getResource(name);
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:15,代码来源:Class.cs


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