String valueOf - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for String valueOf method.

This code example shows how to use the following methods:charAt, length, replaceAll, substring, valueOf
public class AbstractCodegenTestCaseOnAndroid extends TestCase {
 
    protected void invokeBoxMethod(String filePath, String expectedResult) throws Exception {
        try { 
            Class clazz;
            String packageName = filePath.replaceAll("\\\\|-|\\.|/", "_");
            clazz = Class.forName(packageName + "." + getPackageClassName(packageName));
            Method method;
            method = clazz.getMethod("box");
            assertEquals(expectedResult, method.invoke(null));
        } 
        catch (Throwable e) {
            throw new RuntimeException("File: " + filePath, e);
        } 
    } 
 
    public static String getPackageClassName(String packageName) {
        return Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1, packageName.length()) + "Package";
    } 
} 

7
CodeRank
This code example shows how to use the following methods:equals, valueOf
        credentials.put(USERNAME_KEY, username);
        credentials.put(PASSWORD_KEY, password);
        String hostList=null;
        //String hostList = CSS_NODE0 + ":" + RPC_PORT + "," + CSS_NODE1 + ":" + RPC_PORT; 
 
        if(!"".equals(host) && !"".equals(port))
        { 
            hostList=host + ":" + port;
        } 
        else if("".equals(host) && "".equals(port))
        { 
            hostList = LOCAL_NODE + ":" + RPC_PORT;
        } 
        else 
        { 
            if("".equals(host))
            { 
                System.out.println("Host is empty");
            } 
            else 
            { 
5
CodeRank
This code example shows how to use the following methods:lastIndexOf, substring, valueOf
    * @note No '.' dot in the ext. 
    */ 
   public static File replaceExtension( File f, String ext )
   { 
      String s = f.getAbsolutePath();
      int dotPos = s.lastIndexOf(".");
      if ( dotPos > 0 )
      { 
         String result = s.substring(0, dotPos+1);
         result = result + ext;
         return new File( result );
      } 
      else 
      { 
         String result = s;
         result = result + "." +ext;
         return new File( result );
      } 
   } 
} 
5
CodeRank
This code example shows how to use the following methods:valueOf
This code example shows how to use the following methods:indexOf, substring, valueOf
     */ 
    public JCRUtil() { 
        try { 
            URL url = JCRUtil.class.getResource("JCRUtil.class");
            String className = url.getFile();
            String filePath = className.substring(0,className.indexOf(WEBINF) + WEBINF.length());
            String xml;
            Boolean jcrInDb = null;
            try { 
                Context initCtx = new InitialContext();
                jcrInDb = (Boolean) initCtx.lookup("java:/comp/env/JCR_IN_DB");
            } catch (NamingException e ) {
            } 
            System.out.println(jcrInDb);
            if (Boolean.TRUE.equals(jcrInDb)) {
                xml = filePath + "/repository_db.xml";
            } else { 
                xml = filePath + "/repository.xml";
            } 
            String dir = null;

5
CodeRank
This code example shows how to use the following methods:charAt, length, valueOf
	public static String RevStr(String str, int i)
	{ 
		String s="";
		if(str != null)
		{ 
			if(str.length() == 1)
				s = str;
			else if(str.length() > 1 && i < str.length())
			{ 
				s = RevStr(str, i+1) + str.charAt(i);
			} 
		} 
		return s;
	} 
} 
5
CodeRank
This code example shows how to use the following methods:append, setSpan
This code example shows how to use the following methods:append, length, setSpan
			return hint == null ? TYPE_EMPTY : TYPE_HINT;
	} 
 
	private void append(SpannableStringBuilder builder, CharSequence text,
			CharacterStyle span) {
		int start = builder.length();
		builder.append(text);
		builder.setSpan(span, start, start + text.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	} 
 
	@Override 
	public View getView(int position, View convertView, ViewGroup parent) {
		final int type = getItemViewType(position);
		final View view;
		if (convertView == null) {
			final int resource;
			if (type == TYPE_MESSAGE)
				resource = R.layout.chat_viewer_message;
			else if (type == TYPE_HINT)
7
CodeRank
This code example shows how to use the following methods:append
            mSnippet = snippet;
            changed = true;
        } 
 
        if (forceUpdate || changed || (mSubject == null && mSnippet == null) /* first time */) {
            SpannableStringBuilder ssb = new SpannableStringBuilder();
            boolean hasSubject = false;
            if (!TextUtils.isEmpty(mSubject)) {
                SpannableString ss = new SpannableString(mSubject);
                ss.setSpan(new StyleSpan(mRead ? Typeface.NORMAL : Typeface.BOLD), 0, ss.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.append(ss);
                hasSubject = true;
            } 
            if (!TextUtils.isEmpty(mSnippet)) {
                if (hasSubject) {
                    ssb.append(sSubjectSnippetDivider);
                } 
                ssb.append(mSnippet);
            } 

6
CodeRank
This code example shows how to use the following methods:valueOf
        ResultSet rs = null;
 
        try { 
            conn = DriverManager.getConnection(URL, USER, PASS);
            stmt = conn.prepareStatement(INSERT_TOKEN_SQL);
            stmt.setString(1, userId + "_token");
            stmt.setString(2, consumerKey);
            stmt.setString(3, "ACTIVE");
            stmt.setString(4, "PRODUCTION");
            stmt.setString(5, userId);
            stmt.execute();
        } catch (SQLException e)  {
            e.printStackTrace();
        } finally { 
            closeConnection(conn, stmt, rs);
        } 
    } 
 
    public static void addKey(String userId, int applicationId) {
        String INSERT_CONSUMER_APP_SQL = "INSERT INTO IDN_OAUTH_CONSUMER_APPS " +
5
CodeRank

Related String valueOf Questions & Answers:

Other String valueOf Examples

1:	  List<RssItem> list = RssFeedProvider
2:	      .parse("http://www.vogella.com/article.rss");
3:	    String text = String.valueOf(list.size());
4:	  listener.onRssItemSelected(text);
5:	}

Read More

60:	    int lat = (int) (location.getLatitude());
61:	    int lng = (int) (location.getLongitude());
62:	    latituteField.setText(String.valueOf(lat));
63:	    longitudeField.setText(String.valueOf(lng));
64:	  }
-
61:	    int lng = (int) (location.getLongitude());
62:	    latituteField.setText(String.valueOf(lat));
63:	    longitudeField.setText(String.valueOf(lng));
64:	  }
65:

Read More

51:	    String string = button.getText().toString();
52:	    int hitTarget = Integer.valueOf(string) + 1;
53:	    button.setText(String.valueOf(hitTarget));
54:	  }
55:

Read More

2:			SQLiteDatabase db = this.getWritableDatabase();
3:			db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
4:					new String[] { String.valueOf(contact.getID()) });
5:			db.close();
6:		}

Read More

72:			Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
73:					KEY_NAME, KEY_PH_NO }, KEY_ID + "=?",
74:					new String[] { String.valueOf(id) }, null, null, null, null);
75:			if (cursor != null)
76:				cursor.moveToFirst();
-
117:			// updating row
118:			return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?",
119:					new String[] { String.valueOf(contact.getID()) });
120:		}
121:	
-
124:			SQLiteDatabase db = this.getWritableDatabase();
125:			db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
126:					new String[] { String.valueOf(contact.getID()) });
127:			db.close();
128:		}

Read More

123:			// updating row return
124:			int update = db.update(TABLE_RSS, values, KEY_RSS_LINK + " = ?",
125:					new String[] { String.valueOf(site.getRSSLink()) });
126:			db.close();
127:			return update;
-
137:			Cursor cursor = db.query(TABLE_RSS, new String[] { KEY_ID, KEY_TITLE,
138:					KEY_LINK, KEY_RSS_LINK, KEY_DESCRIPTION }, KEY_ID + "=?",
139:					new String[] { String.valueOf(id) }, null, null, null, null);
140:			if (cursor != null)
141:				cursor.moveToFirst();
-
160:			SQLiteDatabase db = this.getWritableDatabase();
161:			db.delete(TABLE_RSS, KEY_ID + " = ?",
162:					new String[] { String.valueOf(site.getId())});
163:			db.close();
164:		}

Read More

valueOf Method Overview
Returns the string representation of the boolean argument.
See Code Examples for other Java 8 String Methods: