From what I have read having a \ will ignore the break character in a Java string. So I have the following code:  //requestedFile is created from a substring from above and contains the string "WebRoot\"  if(requestedFile == "WebRoot\\" { do stuff }   Are these not the same thing?
93
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
10243
I'm quite confused about the following regular expressions I found in a shell script:  ${0##*/} ${0%/*}   How do they work?
121606
I need to determine if a user-supplied string is a valid file path (i.e., if createNewFile() will succeed or throw an Exception) but I don't want to bloat the file system with useless files, created just for validation purposes.  Is there a way to determine if the string I have is a valid file path without attempting to create the file?  I know the definition of "valid file path" varies depending on the OS, but I was wondering if there was any quick way of accepting C:/foo or /foo and rejecting banana.  A possible approach may be attempting to create the file and eventually deleting it if the creation succeeded, but I hope there is a more elegant way of achieving the same result.
32406
Technically, any odd number of backslashes, as described in .  &gt;&gt;&gt; r'\'   File "&lt;stdin&gt;", line 1     r'\'        ^ SyntaxError: EOL while scanning string literal &gt;&gt;&gt; r'\\' '\\\\' &gt;&gt;&gt; r'\\\'   File "&lt;stdin&gt;", line 1     r'\\\'          ^ SyntaxError: EOL while scanning string literal   It seems like the parser could just treat backslashes in raw strings as regular characters (isn't that what raw strings are all about?), but I'm probably missing something obvious.
112817
Before I go and create a custom tag or Java method to do it, what is the standard way to escape HTML characters in JSP?  I have a String object and I want to display it in the HTML so that it appears to the user as is.  For example:  String a = "Hello &lt; World";   Would become:  Hello &amp;lt; World
81820
I'm trying to make a .desktop file for Minecraft. Nothing appears to happen upon executing the file. I've tried assigning the Exec key as follows:  Exec= java -jar "~/.minecraft/Minecraft.jar"  Exec= java -jar "$HOME/.minecraft/Minecraft.jar"  But I'm not sure how to put in the reserved characters (~ and $) correctly. According to Freedesktop's :      If an argument contains a reserved character the argument must be quoted.   and     Quoting must be done by enclosing the argument between double quotes and escaping the double quote character, backtick character ("`"), dollar sign ("$") and backslash character ("\") by preceding it with an additional backslash character. Implementations must undo quoting before expanding field codes and before passing the argument to the executable program.   But that's very confusing to me.
27326
I saw a lot of posts about it all over the internet but i couldn't make it run as i wanted.  I have an input from the user of a path. If the user will type ~/Desktop/ for example i can't use $ans in grep and other commands because of the tilde.   here is an example of my code. the second line is my main problem right now.  read -p "Enter new path or type 'exit':   " ans file=`grep -x $ans ~/.Log`    Appreciate your help.
88566
With this set of commands, what are the {} and \; characters for? find . -name '*.clj' -exec grep -r resources {} \;
107731
I'm learning Bash, and I want to replace space characters with other "non blank" characters. I'm using a for loop:  for f in *\ *; do mv "$f" "${f// /_}"; done   My question is, why are the double slash and the space in ${f// /_}? What does ${f// /_} do?
58268
In Java, given a java.net.URL or a String in the form of http://www.example.com/some/path/to/a/file.xml , what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file".   I can think of several ways to do this, but I'm looking for something that's easy to read and short.
14412
I have created a function wherein I split a string from the csv filecsvAsString.split('\n') . It is working when the string is not so big. But when I try to split a very large string, an error will occur      regex too complicated   what I want to do is to catch if an error occur during the split process. How will I do it ? I've tried to use try and catch but the problem still occur. Is there any other possible solution?
42663
I have an input String say Please go to http://stackoverflow.com. The url part of the String is detected and an anchor &lt;a href=""&gt;&lt;/a&gt; is automatically added by many browser/IDE/applications. So it becomes Please go to &lt;a href='http://stackoverflow.com'&gt;http://stackoverflow.com&lt;/a&gt;.  I need to do the same using Java.
105396
What is the difference between  char str1[32] = "\0";   and   char str2[32] = "";
9051
Check out the below program.   try {     for (String data : Files.readAllLines(Paths.get("D:/sample.txt"))){         String[] de = data.split(";");         System.out.println("Length = " + de.length);     } } catch (IOException e) {     e.printStackTrace(); }   Sample.txt:   1;2;3;4 A;B;; a;b;c;   Output:   Length = 4 Length = 2 Length = 3   Why second and third output is giving 2 and 3 instead of 4. In sample.txt file, condition  for 2nd and 3rd line is should give newline(\n or enter) immediately after giving delimiter for the third field. Can anyone help me how to get length as 4 for 2nd and 3rd line without changing the condition of the sample.txt file and how to print the values of de[2] (throws  ArrayIndexOutOfBoundsException)?
6296
What regex pattern would need I to pass to  java.lang.String.split()  to split a String into an Array of substrings using all whitespace characters (' ', '\t', '\n', etc.) as delimiters?
4470
As per the following example, and as in  In bash, where has the trailing newline char gone?, I want to know "why" it happens    x="$(echo -ne "a\nb\n")" ; echo -n "$x" | xxd -p  # Output is: 610a62  # The trailing newline from the 'echo' command #   has been "deleted" by Command Substitution   I assume there must be some very significant reason for a shell action, namely Command Substitution, to actually delete some data from the command output it is substituting... but I can't get my head around this one, as it seems to be the antithesis of what it is supposed to do.. ie. to pass the output of a command back into the script process... Holding back one character seems weird to me, but I suppose there is a sensible reason for it...  I'm keen to find out what that reason is...
6438
In my bash script I have an external (received from user) string, which I should use in sed pattern.  REPLACE="&lt;funny characters here&gt;" sed "s/KEYWORD/$REPLACE/g"   How can I escape the $REPLACE string so it would be safely accepted by sed as a literal replacement?  NOTE: The KEYWORD is a dumb substring with no matches etc. It is not supplied by user.