In a certain Java class for a Struts2 web application, I have this line of code:
try {
user = findByUsername(username);
} catch (NoResultException e) {
throw new UsernameNotFoundException("Username '" + username + "' not found!");
}
My teacher wants me to change the throw statement into something like this:
static final Strin...
I have a List:
List<int> list = new List<int> {1, 2, 3, 4, 5};
If want to get string presentation of my List. But code list.ToString() return "System.Collections.Generic.List'1[System.Int32]"
I am looking for standard method like this:
string str = list.Aggregate("[",
(aggregate, value) =>
...
How do I declare a simple string "test" to a variable?
...
Hello everyone!
Background story:
There are these Source and Result interfaces for XML.
These are adapters between different XML technologies in Java.
Instances of these classes represent DOM, SAX, JAXB, XML streams, XML events
(and even more?).
The question:
So, is there something comparable for plain old strings? Some generalizatio...
I want to know which is the preferred way to declare a string in C#:
string strEmpty = String.Empty;
or
string strNull = null;
Which practice is better or what is the difference between these statements.
...
I'm trying to create am online application for some job postings we have at work.
I have the form items (text boxes / drop downs /etc) portion set up and i have the send email with a captcha part setup
im unclear on how to "call" the value of something like
<select name="education">
<option value="None">None</option>
<option...
This is my first time using XSLT. I'm trying to create a file that will convert an XML data file exported from a program I use to an HTML report.
One of the element's value is path to an image file, but the path generated is an absolute path such as
C:\Documents and Settings\me\Desktop\xml export\cd000402.jpg
but I want a relative pa...
There is a read-only library function that takes a file as an argument.
But I have a string.
How do I convert a string to a file, that if you read the file it will return this string?
I don't want to write to disk.
...
I have a string named group.
string group="|17|11|";
So my issue is that I want my output to be something like this:
17
11
so these 2 numbers should be stored in the database as two records. and another case if the
string group = "|17|11|05|";
it will store 3 values in the database. The number of groups always differs in differe...
Hi there
I'm using jquery to get the last word in a string,
but i want to be sure it is the best way (performance wise),
because the string could get very long
furthermore, i want to add capability to get the "current" word,
which may not simply be the last word..
This is my code so far
<script type="text/javascript">
function ...
Is there anything like this in Standard C++ / STL? Ideally it should be constructed like
fstring s = fstring(10);
I need to sometimes construct or have a string of fixed size. Sometimes to be able to read / write only that many characters into a stream.
Edit:
Note that the size is only known at runtime, and is different from one to...
Is conversion to String in Java using
"" + <int value>
bad practice? Does it have any drawbacks compared to String.valueOf(...)?
Code example:
int i = 25;
return "" + i;
vs:
int i = 25;
return String.valueOf(i);
Update: (from comment)
And what about Integer.toString(int i) compared to String.valueOf(...)?
...
Hi,
I was wondering if you could help me out with a C string problem I don't quite understand. I have a function to which I send 3 char pointers. Within this function, the char pointers are shifted and modified correctly. However, when I return to the main function from which they are called, said functions are not changed. Am I passing ...
Everyone knows the "=" sign.
SELECT * FROM mytable WHERE column1 = column2;
However, what if I have different contents in column1 and column2...but they are VERY similar? (maybe off by a space, or have a word that's different).
Is it possible to:
SELECT * FROM mytable WHERE ....column matches column2 with .4523423 "Score"...
I bel...
I'm making a stupid little game that saves your score in a highscores.txt file.
My problem is sorting the lines. Here's what I have so far.
Maybe an alphanumeric sorter for python would help? Thanks.
import os.path
import string
def main():
#Check if the file exists
file_exists = os.path.exists("highscores.txt")
scor...
I am not sure what exactly the issue is here. I am working with 2 strings and I keeping getting the error "A field initializer cannot reference the non-static field, method, or property 'Captcha.Capture.CaptureTime'".
Here's a snippet from the code:
string CaptureTime = DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()...
Given 2 strings, I want to find the first match of at least four characters.
This is the code I currently have to do it. It works correctly, but I'm thinking there may be a better way to do this. Are there any screaming inefficiencies or bad practices in what I'm doing? Are there common libraries, like Apache Commons, that I should be t...
I need a way to create a string of n chars. In this case ascii value zero.
I know I can do it by calling the constructor:
string sTemp(125000, 'a');
but I would like to reuse sTemp in many places and fill it with different lengths.
I am calling a library that takes a string pointer and length as an argument and fills the string with ...
I want to get the first few words(100 or 200) from a long summary of words (plain string or html) using c#.
My requirement is to display the short description of the long summary of content(this content may include html elements). I'm able to retrieve the plain string but when it is html, the elements are cut it between Example, I get l...
The first example does not work when you go to delete the pointer. The program either hangs when I add the null terminator or without it I get:
Debug Assertion Failed Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) from Visual Studio 2008
//Won't work when deleting pointer:
char *at = new char [3];
at = "tw"; // <-- not sure what'...