|
I like to encode a java map of strings as a single base 64 encoded string. The encoded string will be transmitted to a remote endpoint and maybe manipulated by a not nice person. So the worst thing that should happen are invaild key,value-tuples, but ...
Started by Chris on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The the encoding then would look like this:
JSONObject jso = new JSONObject( map ); String encoded = new String(Base64.encodeBase64( jso.toString( 4 ).toByteArray()));
my primary requirements are: encoded string should be as short....
|
|
I would like to split a string into a String[] using a String as a delimiter.
String delimit = "[break]"; String[] tokens = myString.Split(delimit);
But the method above only works with a char as a delimiter.
Any takers?
Started by Kieran on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I have no idea why there isn't a string.....
Like this:
mystring.Split(new string[] { delimit }, StringSplitOptions.None);
For some reason, the only overloads of Split that take a string take it as an array, along with a StringSplitOptions .
|
|
Or a better way than this?
String concat(String[] strings) { StringBuilder out = new StringBuilder(); for(String next: strings) { out.append(next); } return out.toString(); }
No worries if no, I just feel like there should be a built in?
Started by gav on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Strs) { int size = 0; for (String....
I guess if you want to be uber efficient, you could write it as something like:
public static String concat(String...
In the posh for loop was to do a string join (which you can do without anyway).
|
Ask your Facebook Friends
|
In C# what is the difference between String and string? (note the case)
Also, what are the guidelines for the use of each?
Started by Lance Fisher on
, 16 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
string....
As far as guidelines, I think it's generally recommended to use string any time you're referring to an object.
System.Int32.
It's like int vs.
So technically, there is no difference.
string is an alias for System.String .
|
|
Hello,
I have a question about comparing a string with the empty string in Java. Is there a difference, if I compare a string with the empty string with == or equals? For example:
String s1 = "hi"; if (s1 == "")
or
if (s1.equals(""))
I know that one should...
Answer Snippets (Read the full thread at stackoverflow):
If you create the string with
new String("")
Then it will never match "" with the equals operator, as shown below:
String one = ""; String two = new String....
It's going to depend on if the string is a literal or not.
|
|
Duplicate of this question .
I'm learning C++ at the moment, and I'm coming across a lot of null-terminated strings. This has got me thinking, what makes more sense when declaring pointers:
char* string
or
char *string
? To me, the char* format makes ...
Started by Skilldrick on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
Just offering another POV
In most cases, std::string str * string;
Consider, if Dennis Ritchie (designer od the C language) instead of using the '*' character had used a keyword 'ptr', we would....
Simplify definitions a few times as well.
|
|
Hi,
I have an json output of the following (ignore the escape characters)
"{\"sEcho\":1,\"iTotalRecords\":10,\"iTotalDisplayRecords\":10,\"aaData\":[{\"Job\":\"developer\",\"Name\":\"kurt\"},{\"Job\":\"plumber\",\"Name\":\"john\"}]}"
which i get from
...
Started by kjm on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
My guess is that instead of a Person object, you'd have to create a List for each Person, putting string MakeJsonLikeStr(object o) { string json = JsonConvert.SerializeObject(o); return json.Replace.
|
|
In C# the string keyword (highlighted in Visual Studio as a data type) is just a shortcut to the String class right?
In that case, it would be the same to use either while coding from the semantic point of view. However, is it the same from the performance...
Started by Toto on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Lowercase "string" is preferred in most projects due to the syntax highlighting
string is just an alias....
There are no performance implications either way.
string and String are identical in all ways (except the uppercase "S").
|
|
In asp.net MVC I have a search action in my controller and I am trying to decide If I should pass the query to my repository as a string
public ActionResult Search(string query) { return View(_repository.ListPeople(query)); }
or as individual parameters...
Started by Graham on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Looking at it from a separation of concerns.
Repository be in charge of getting data, it shouldn't have to do any kind of parsing of a query string take on the responsibility of parsing a query string.
|
|
When you're in a relationship with no strings attached is it difficult to make that person a puppet in your? hands
Started by Ghost of Arlanymor Mountain Man on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at yahoo):
Not at all because I know how to pull the right strings to make them react a relationship with no strings? YUP.
|