I have a program where commands are executed through Runtime.getRuntime().exec(cmdArray[]). The user can append additional switches to these commands by entering them in a textbox.  Example:  cmdArray[] = {"someprogram", "--something", "123"} //this is the initial command //textbox is   -A "bla bla bla"   notice the quotes  //do something...  cmdArray[] = {"someprogram", "--something", "123", "-A", "bla bla bla"} //parsed array   Is there a java function that would allow me to do this? or do I have to write it myself (sounds tedious since I have to handle the single and double quotes, all the escaping etc...)?  Thanks  EDIT: Didn't want the extra dependency so I wrote a simple method, it doesn't cover everything but it does what I want  public String[] getCmdArray(String cmd) { // Parses a regular command line and returns it as a string array for use with Runtime.exec()     ArrayList&lt;String&gt; cmdArray = new ArrayList&lt;String&gt;();     StringBuffer argBuffer = new StringBuffer();     char[] quotes = {'"', '\''};     char currentChar = 0, protect = '\\', separate = ' ';     int cursor = 0;     cmd = cmd.trim();     while(cursor &lt; cmd.length()) {         currentChar = cmd.charAt(cursor);          // Handle protected characters         if(currentChar == protect) {             if(cursor + 1 &lt; cmd.length()) {                 char protectedChar = cmd.charAt(cursor + 1);                 argBuffer.append(protectedChar);                 cursor += 2;             }             else                 return null; // Unprotected \ at end of cmd         }          // Handle quoted args         else if(inArray(currentChar, quotes)) {             int nextQuote = cmd.indexOf(currentChar, cursor + 1);             if(nextQuote != -1) {                 cmdArray.add(cmd.substring(cursor + 1, nextQuote));                 cursor = nextQuote + 1;             }             else                 return null; // Unprotected, unclosed quote         }          // Handle separator         else if(currentChar == separate) {             if(argBuffer.length() != 0)                 cmdArray.add(argBuffer.toString());             argBuffer.setLength(0);             cursor++;         }          else {             argBuffer.append(currentChar);             cursor++;         }     }      if(currentChar != 0) // Handle the last argument (doesn't have a space after it)         cmdArray.add(argBuffer.toString());      return cmdArray.toArray(new String[cmdArray.size()]); }  public boolean inArray(char needle, char[] stack) {     for(char c : stack)         if(needle == c)             return true;     return false; }
What is a good way of parsing command line arguments in Java?
Inspired by  which states limb loss as a recurring theme, I started thinking about the final lightsaber battle. After watching The Force Awakens the second time, I was not sure if      Kylo Ren   lost a limb or just lost his lightsaber. We definitely see      Rey slash at Ren’s right hand.   So knowing that context:      Did Kylo Ren actually lose his arm/hand? Label PGFPlot table points with coordinates I would like to label each plotted point with its x and y coordinate. I am able to label with a single one using the MWE below. I must avoid manually labeling each point since my actual table size is larger and will be changed out regularly. \documentclass{standalone}   \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.16}  \begin{document}  \pgfplotstableread[col sep=&amp;,row sep=\\]{  x     &amp;  y     \\  0.940 &amp;  0.992 \\  0.992 &amp; -0.940 \\ -0.992 &amp;  0.940 \\ -0.940 &amp; -0.992 \\ }\mytable  \begin{tikzpicture}  \begin{axis}     \addplot+[only marks, nodes near coords]table[x=x,y=y,meta=x]{\mytable}; \end{axis}  \end{tikzpicture} \end{document}  which creates the following figure  The desired output is for each point to be labelled with both coordinates. For specific example the top left point would be labelled with &quot;(0.94, 0.992)&quot;. Concecutive last zeroes in expansion of $100!$ std::thread - "terminate called without an active exception", don't want to 'join' it Can sudo be reinstalled after being removed? I'd really value your thoughts on this one. I'm familiar with the following use of 'made of':  The shirt is made of silk.  But I'd like to know if anyone thinks using this phrasal verb as a synonym for comprise/consist of/be composed of/made up of is actually grammatically correct/non-standard usage.  The board is made of five members. The board is made up of five members.  A few instances of this usage came up on a google search, but I'm not convinced... Sci-Fi book female fighter pilot All I remember about the book is that the protagonist was a human female fighter pilot, she has short hair, not sure if it was blond or auburn and she was involved in making peace with the alien race.  The alien race was invading Earth, but because of her they stopped, surrendered and because of her helped Earth improve its technology. I remember that she melded with something and was starting to sort of think like them and lose a bit of her humanity.  It was set in the not too distant future. I believe I read it in the 90s. How does Drupal 8 know what module needs updating and to what version he needs to update?  I have build a module and I'm trying to update it (adding a table). I implemented a update hook numbered 8001, which is the first update, but when I go to update.php Drupal does not see any update for my module.  I expect there must be a place in my module where I can define the current version of my module and another place in the database where Drupal stores the latest installed update of my module. (I need this for debugging the update script later on.) Can I use HMAC-SHA1 in counter mode to make a stream cipher? Say I have an embedded device which is only capable of doing HMAC-SHA1 transformations (that device is, in fact, a YubiKey).  Would it be secure to feed it like a block cipher in counter mode to get a random pad suitable as an stream cipher?  Of course, I'm talking about not repeating the counter value ever to encrypt data (so this construction would also need some random IV or treating the counter value as a nonce forever). Proving that if $G/Z(G)$ is cyclic, then $G$ is abelian Possible Duplicate:             If $G$ is a group and $Z(G)$ the center of $G$, show that if $G/Z(G)$ is cyclic, then $G$ is abelian.  This is what I have so far:  We know that all cyclic groups are abelian. This means $G/Z(G)$ is abelian.  $Z(G)= \{z \in G \mid zx=xz \text{ for all } x \in G \}$.  So $Z(G)$ is abelian.    Is it sufficient to say that since $G/Z(G)$ and $Z(G)$ are both abelian, $G$ must be abelian? Prove that 1/2 + 1/4 + 1/8 ....... = 1 I've often heard that instead of adding up to a little less than one, 1/2 + 1/4 + 1/8... = 1. Is there any way to prove this using equations without using Sigma, or is it just an accepted fact? I need it without Sigma so I can explain it to my little sister.  It is not a duplicate because this one does not use Sigma, and the one marked as duplicate does. I want it to use variables and equations. Given n distinct objects, there are $n!$ permutations of the objects and $n!/n$ "circular permutations" of the objects (orientation of the circle matters, but there is no starting point, so $1234$ and $2341$ are the same, but $4321$ is different).  Given $n$ objects of $k$ types (where the objects within each type are indistinguishable), $r_i$ of the $i^{th}$ type, there are   \begin{equation*} \frac{n!}{r_1!r_2!\cdots r_k!} \end{equation*}  permutations.  How many circular permutations are there of such a set? What makes a good entry level road bike? I've been riding a mountain bike for years, but I prefer to go longer distances on paved ground, so I think a road bike would be better. When I ask what is a good bike, I don't need brands or models - more like what components of the bike should I look for, and what should I avoid? Additionally, is it necessary to "go big or don't go at all" as far as spending - getting a real good quality road bike for $500 to a few thousand, or should I cheap out on a $100-200 road bike, as it is my first, then get a better one when I'm more experienced? Let $R$ be a UFD. Then for any two elements $a,b \in R \setminus \{0\}$ $ab \sim \gcd (a,b){\operatorname{lcm} (a,b)}$.   My attempt :  Let $d = \gcd (a,b)$.Then $d|a$ and $d|b$.Then $\exists x,y \in R$ such that $a = dx$ and $b = dy$.Now it is to be shown that $c = dxy$ is the lcm of $a,b$.Which I find difficulty to show.It is clear that $a|c$ and $b|c$. Now if $u$ is any common multiple of $a$ and $b$.Then $dx|u$ and also since $y|b$ we have $y|u$ i.e. $dxy|u^2$ $\implies c|u^2$.But I have to show $c|u$ to complete the proof which I fail to prove.Please help me to complete the proof.  Thank you in advance. What was missing in Dirac's argument to come up with the modern interpretation of the positron? Salesforce to Xero integration using Named Credentials by OAuth 2.0 How do I switch between keyboard layouts? I want to switch between English and another language.  I have tried Lubuntu and it was easy, I figured it out from the friendly menus. But in Ubuntu everything is so cryptic. Does the refresh rate affect LCD screens? I have never really paid any attention to the refresh rate setting on computers with LCD screens.  I thought with LCD displays the pixels are either on or off, they don't flicker like in old CRT monitors.  Seems trivial to me, but my own graphics card allows me to select 59Hz or 60Hz - which leads me onto my question:  Does the refresh rate affect LCD screens?  Technical info to back up any answers would be great. I'm attempting to install Ubuntu 14.04.1 (the only version I have handy) onto my old Compaq Presario R3000 (this Ubuntu was recommended for this computer). The installation has stalled at about 60% and hasn't moved in an hour.  The message at the bottom says: Configuring bcmwl-kernal-source (i386).  I have no experience with Ubuntu (or with Linux, for that matter), coming from a strictly-Windows background). Can anyone offer some advice? How to force the user to download a file, not to view it?