So the gist of my program is that it will read some commands from a file and then perform certain operations judging by the commands. My problem is that my code isn't reading all of the lines of the txt document. Specifically, it reads the first four lines which I tested by previously inputting a print statement inside of the if statement that tests to see if the input = "P". Any help would be much appreciated.  Here is the txt document as well  P e1 10 5  P e2 19 5  P e3 11 5  P e4 18 5  R mouth 10 10 10 2  S nose 14 7 2  P p3 9 9  P p4 20 9  D  Y bad command  M p3 9 12  M p4 20 12  D    public static void main(String[] args) {            String filename = args[0];           File file = new File(filename);            Scanner input=null;            try {                 input=new Scanner(file);              }           catch(java.io.FileNotFoundException ex) {                System.out.println("ERROR: Couldn't open file: " + file);                System.exit(1);           }            AsciiDisplay asciiDisplay= new AsciiDisplay();            while(input.hasNext()) {                if(input.next().equals("P")) {                      String id=input.next();                     int x=input.nextInt();                     int y=input.nextInt();                     Coordinate coordinate=new Coordinate(x,y);                     Point point=new Point(id,coordinate);                     asciiDisplay.addShape(point);                 }                else if(input.next().equals("R")) {                     String id=input.next();                     int x=input.nextInt();                     int y=input.nextInt();                     int length=input.nextInt();                     int height=input.nextInt();                     Coordinate coordinate= new Coordinate(x,y);                     Rectangle rectangle= new Rectangle(id,coordinate,length,height);                     asciiDisplay.addShape(rectangle);                 }                 else if(input.next().equals("S")) {                      String id=input.next();                     int x=input.nextInt();                     int y=input.nextInt();                     int size=input.nextInt();                     Coordinate coordinate= new Coordinate(x,y);                      Square square = new Square(id,coordinate,size);                     asciiDisplay.addShape(square);                 }                 else if(input.next().equals("M")) {                      String id=input.next();                     int x=input.nextInt();                     int y=input.nextInt();                     Coordinate coordinate= new Coordinate(x,y);                     asciiDisplay.moveShape(id,coordinate);                 }                 else if(input.next().equals("E")) {                      asciiDisplay.deleteAll();                 }                 else if(input.next().equals("D")) {                     asciiDisplay.updateGrid();                     asciiDisplay.printGrid();                 }                else if(input.next().equals("X")) {                   System.out.println("Invalid command: X");                  }             }      } }
I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on the sites I've visited.  Is there a better/different way to read a file into a string in Java?  private String readFile(String file) throws IOException {     BufferedReader reader = new BufferedReader(new FileReader (file));     String         line = null;     StringBuilder  stringBuilder = new StringBuilder();     String         ls = System.getProperty("line.separator");      try {         while((line = reader.readLine()) != null) {             stringBuilder.append(line);             stringBuilder.append(ls);         }          return stringBuilder.toString();     } finally {         reader.close();     } }
Cohen's d for 2x2 interaction I have a significant 2x2 interaction in a between-subjects design.  I would normally report omega-squared as my effect-size measure, but I've been asked to provide Cohen's d instead?  Can Cohen's d be computed for an interaction?  If so, how? Is there a nice solution to get a "presenter mode" for Latex presentations? I wanted a list of sub-domains of Stack Exchange that are not mentioned over here   Some of the sub-domains I found which were not mentioned are       Are there any other which are not mentioned?    Mentions by , ,             Other mentions below which are not mentioned in "All Sites" but are mentioned in the drop down menu on the top left of the Stack Exchange website         Any other website that's left out ? (c) Let $\mathcal{L}^*\subseteq\mathcal{L}^{\text{FOPC}}$ be a first order language of predicate calculus consisting of three unary function symbols $f,g,h$.  (i) Write down an $\mathcal{L}^*$-sentence $\phi$ such if $\mathcal{A}$ is an $\mathcal{L}^*$-structure with $\mathcal{A}\vDash\phi$ then the restriction of $h_\mathcal{A}$ to the range of $f_\mathcal{A}$ gives a one-to-one function onto the range of $g_\mathcal{A}$.  (ii) Write down an $\mathcal{L}^*$-sentence $\psi$ such that if $\mathcal{A}$ is an $\mathcal{L}^*$-structure with $\mathcal{A}\vDash\psi$ and the domain $A$ of $\mathcal{A}$ is finite then the cardinality $|A|$ is a square.    Part (i) is easy enough, but I'm having trouble with part (ii). I assume that you can use part (i). My initial idea was to use $h$ to ensure $|Range(f_A)| =|Range(g_A)|$ but I'm not sure where to go from there. Thanks. In the IEEE 802.3 frame structure there is a 7 byte preamble section for synchronization. If it is really for synchronization does that mean Ethernet is synchronous and not asynchronous?    Ethernet structure for reference: Similar matrices and minimal polynomial I have a file as below:  mime PI Name: ISHO SUCCESS RATE RT, Value: 95.663826 scr  PI Name: RRC Access Failures due to UU, Value: 0.13394141 prog PI Name: RRC Access Failures due to UU, Value: 0.16077702 sch PI Name: RRC Access Failures due to UU, Value: 0.11781933   I want to remove text PI till Value:. I tried   sed '/&lt;PI&gt;/,/&lt;\/Value:&gt;/d'    Any help? Extracting raster values at points using Open Source GIS? Choice function for collection of arbitrary finite sets. AC required? Cannot Buy Land in Falkreath Whenever both my roommate and I use the wifi in a certain room in our apartment, it slows dramatically for me. It doesn't slow for him. If he uses it in another room, it's fine; if I use it in another room together with him, it's fine; it's just in this particular room. Does anyone know of a reason this could be? Rich Snippets not working (and working at the same time?) ANOVA analysis with only mean and standard deviation What packages do people load by default in LaTeX? I'm getting the impression from reading the answers written by some of the real experts here that there are quite a few little packages that just tweak LaTeX2e's default behaviour a little to make it more sensible here and there.  Rather than try to pick these up one by one as I read answers to questions (and thus risk missing them), I thought I'd ask up front what LaTeX2e packages people load by default in (almost) every document.  As this is a "big list" question, I'm making it CW.  I don't know if there are standard rules across all SE/SO sites for such questions, but on MathOverflow the rule is generally: one thing (in this case, package) per answer.  I guess that if a couple of packages really do go together then it would be fine to group them.  This is perhaps a little subjective and a little close to the line, so I'll not be offended if it gets closed or voted down!  (But please explain why in the comments.)  Also see our community poll question: Cannot set LD_LIBRARY_PATH in /etc/profile.d Why "a user" instead of "an user"? I am getting confused while using an article an. Because an is used while referring to vowels (a,e,i,o,u).  But today I read an article where for user they used a user.  My question is, why was an not used?  Could someone explain this with an example? Why Re-throw Exceptions? I've seen the following code many times:  try {     ... // some code } catch (Exception ex) {     ... // Do something     throw new CustomException(ex);      // or     // throw;      // or     // throw ex; }   Can you please explain the purpose of re-throwing an exception? Is it following a pattern/best practice in exception handling? (I've read somewhere that it's called "Caller Inform" pattern?) Non-trivial cyclic group with unique generator Let $G$ be a non-trivial cyclic group with an unique generator. Show that $G$ has exactly two elements.   Let $g$ be a generator of $G$. My first idea to approach the problem was to show that if $|G|=n &gt; 2$ then there is an integer $k$ between 1 and $n$ such that $\langle g^k \rangle = G$ or, equivalently, $g \in \langle g^k \rangle$. My second idea was to analyse the problem in 2 separate cases. For the first one, if $n$ is prime, let $k$ be a positive integer then, by Lagrange's Theorem, $|g^k| \mid n$ and, therefore, $\langle g^k \rangle = n$. Hence, we must conclude that, if $n &gt; 2$ the generator cannot be unique. For the second case, where $n$ is composite, I was hoping to get to a contradiction, but could not advance any further. Is there a way to develop either of these ideas or is it necessary a new approach? Can I use a present-tense verb when writing about a past event? Multiple chrome.exe processes in Task Manager I know that each new tab on Google Chrome have its own process, but I have 14 chrome.exe processes running actually as I can see it on the Task Manager, and only two tabs are opened on Google Chrome.    Could it be due to Chrome extensions? What other reason can open more chrome.exe process and how to avoid it?