I'm trying to become familiar with file I/O in Java. I started off by getting a lot of errors when compiling, such as error: unreported exception IOException; must be caught or declared to be thrown. So I made some changes to the code and ended up with:  public static void main(String[] args){     FileInputStream in = null;     FileOutputStream out = null;     String content = "hello";     byte[] contentBytes = content.getBytes();      try{         out = new FileOutputStream("output.txt");         out.write(contentBytes);     }catch(IOException e){      }catch(FileNotFoundException e){      }     finally{         if (out != null)             out.close();     } }   Still, I get this error:  FileIO.java:16: error: exception FileNotFoundException has already been caught         }catch(FileNotFoundException e){          ^ FileIO.java:21: error: unreported exception IOException; must be caught or declared to be thrown                 out.close();                          ^ 2 errors    Where did I "already catch" FileNotFoundException? Because of the second error, do I need to put another try and catch statement in the finally clause to catch IOException? That seems messy and over-complicated. Am I doing something else wrong? And why doesn't java let me do what I want without forcing me to catch exceptions?   EDIT:  If I do:  public static void main(String[] args){     FileOutputStream out = null;     String content = "hello";     byte[] contentBytes = content.getBytes();      try{         out = new FileOutputStream("output.txt");         out.write(contentBytes);     }catch(FileNotFoundException e){      }catch(IOException e){      }     finally{             if (out != null)             out.close();      } }   I get:  FileIO.java:20: error: unreported exception IOException; must be caught or declared to be thrown                 out.close();                          ^ 1 error
Alright, I have been doing the following (variable names have been changed):   FileInputStream fis = null; try {     fis = new FileInputStream(file);      ... process ...  } catch (IOException e) {     ... handle error ... } finally {     if (fis != null)         fis.close(); }    Recently, I started using FindBugs, which suggests that I am not properly closing streams.  I decide to see if there's anything that can be done with a finally{} block, and then I see, oh yeah, close() can throw IOException.  What are people supposed to do here?  The Java libraries throw too many checked exceptions.
Finding Stack Overflow/Exchange users based on geographic area? I want to click on file to inherit the name for the file being saved. I can't read file names in the dialog box because the color is too faint. This is the same question as   That question does not have an answer but I don't have enough points to interact there so I have to post a new question.    Edited to add screen shots I tried to calibrate the monitor which no effect and did not change the readability of "unavailable" file names. I have added screenshots of previous operating systems to compare: Please tell me how Mojave is not to blame here: Suppose Pat is male. Which one is correct?     I found out Pat is male.      I found out Pat was male.   Does the following change make any difference?     She said Pat is male.      She said Pat was male.   Suppose you created a mathematical model. When you are describing a result, which one (or neither) is correct?     The model analysis shows that the equilibrium is stable.      The model analysis showed that the equilibrium is stable. Let the ring of fractions be denoted as $S^{-1}R$.       Proposition (from Robert Ash's textbook "Basic Abstract Algebra")      Define $f: R \rightarrow S^{-1}R$ by $f(a) = a/1$. Then f is a ring homomorphism. If S has no zero divisors then f is a monomorphism, and we say that R can be embedded in $S^{-1}R$. In particular:      (i) A commutative ring R cna be embedded in its complete (or *full) ring of fractions ($S^{-1}R$, where S consists of all non-divisors of zero in R).       (ii) An integral domain can be embedded in its quotient field.    Why does the proposition say "If S has no zero divisors..."? If S really had zero divisors, then this wouldn't even be properly defined, right? Because we would have a/0 for some a in R. When training a neural network using the back-propagation algorithm, the gradient descent method is used to determine the weight updates. My question is: Rather than using gradient descent method to slowly locate the minimum point with respect to a certain weight, why don't we just set the derivative $\frac{d(\text{Error})}{dw}=0$, and find the value of weight $w$ which minimizes the error? Also, why are we sure that the error function in back-propagation will be a minimum? Can't it turn out the error function is a maximum instead? Is there a specific property of the squashing functions that guarantees that a network with any number of hidden nodes with arbitrary weights and input vectors will always give an error function that has some minima? Proving inequality $(a+\frac{1}{a})^2 + (b+\frac{1}{b})^2 \geq \frac{25}{2}$ for $a+b=1$ combining results of two select statements How to calculate $f(x)$ in $f(f(x)) = e^x$? How would I calculate the power series of $f(x)$ if $f(f(x)) = e^x$?  Is there a faster-converging method than power series for fractional iteration/functional square roots? How can I add four spaces before each lines of programs code in terminal Does a differentiable everywhere function have a continuous derivative? If a function $f$ defined on $[a,b]$ and differentiable everywhere, does it mean that its derivative $f'(x)$ is continuous everywhere on $[a,b]$?  My understanding is 'yes'. Because if there were 'a gap' in $f'(x)$, we could integrate back to $f(x)$ and show that where the gap is, there would be a sharp "angle" where $f(x)$ is not differentiable. Why is $l^\infty$ not separable? "Stack Overflow requires external JavaScript from another domain" message is error 404  Well, it seems that Wget picks it up so the last statement is false and the exact message is:  Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.   and it loads in Chrome once after I clear the cache but not after. I am looking for either an online tool or one that I can download to convert DD to DMS.  For example, I want to convert from:  41.590833, -93.620833 to 41° 35′ 27″ N, 93° 37′ 15″ W ...  Those are the coordinates, according to , for Des Moines. How many different permutations are there of the sequence of letters in "MISSISSIPPI"? I am designing the layout for a touchscreen for outside use, What are some good color combination to use that will be visible under the sun light for outside use? Maybe bright neon colors? Prove that $\sum\limits_{k=0}^m\binom{m}k\binom{n}{r+k}=\binom{m+n}{m+r}$ using combinatoric arguments. Prove that $$\sum\limits_{k=0}^m\binom{m}k\binom{n}{r+k}=\binom{m+n}{m+r}$$ using combinatoric arguments.   I prefer you to answer using an analogy to a combinatoric problem or else I'll have trouble understanding.  I tried:  Let $m$ represent a group of boys and $n$ represent a group of girls. We want to form a committee with the condition that there must be $r$ more girls than boys on the committee. There's two ways of doing this. (I'm having trouble with the right-hand side.)  The left-hand side is one way of doing this. So we split the problem to different cases. One such case is where there are no boys on the committee, and so, there's $\binom{m}0\binom{n}{r+0}$ ways of forming a committee. Next, we can have 1 boy on the committee. There's $\binom{m}1\binom{n}{r+1}$ ways to do this. We repeat this process until we have $\binom{m}k\binom{n}{r+k}$ ways of forming a committee. Summing up the cases will result in the right-hand side. However, as stated before, I don't really know how to explain the right-hand side. Maybe I used the wrong analogy? Mechanism to prevent edits without approval? I would say a quarter to half my questions end up getting edited the vast majority of which end up dramatically changing the context of my question. I'm not against good advice (I've acted on about 2% of all the criticisms I have ever had about my work since they were actually thoughtful) though I think since I joined overflow sites years after I've had a good grip on most of the material I work with people are seeing low reputation and presuming that equates to low levels of comprehension.  Regardless of the reasoning behind people making edits is there an option I can use that would require my approval in order to commit an edit to my questions?   I have no interest in spamming questions in order to artificially boost my reputation. I am getting tired of having to add bullet points telling people to ask for clarifications instead of editing my posts. Having to correct my posts so often reduces my desire to ask the question if I have to review the question again (even with the revision pages available). As this is a discussion there is no reason to edit this post, I will be happy to revise my own if you leave comments as I actively follow questions I participate in though the office of redundancy redundancy requires that I state I know what I am asking.   For example, say I post about Kubuntu (which by default uses KDE) and someone edits it changing the OS to Ubuntu (which uses Gnome by default). Then, answers become Gnome-oriented for a KDE question and the entire context has been changed--negating the point of asking the question in the first place. Find a closed form of the series $\sum_{n=0}^{\infty} n^2x^n$ The question I've been given is this:  Using both sides of this equation:  $$\frac{1}{1-x} = \sum_{n=0}^{\infty}x^n$$  Find an expression for $$\sum_{n=0}^{\infty} n^2x^n$$ Then use that to find an expression for $$\sum_{n=0}^{\infty}\frac{n^2}{2^n}$$  This is as close as I've gotten:  \begin{align*} \frac{1}{1-x} &amp; = \sum_{n=0}^{\infty} x^n \\ \frac{-2}{(x-1)^3} &amp; = \frac{d^2}{dx^2} \sum_{n=0}^{\infty} x^n \\ \frac{-2}{(x-1)^3} &amp; = \sum_{n=2}^{\infty} n(n-1)x^{n-2} \\ \frac{-2x(x+1)}{(x-1)^3} &amp; = \sum_{n=0}^{\infty} n(n-1)\frac{x^n}{x}(x+1) \\ \frac{-2x(x+1)}{(x-1)^3} &amp; = \sum_{n=0}^{\infty} (n^2x + n^2 - nx - n)\frac{x^n}{x} \\ \frac{-2x(x+1)}{(x-1)^3} &amp; = \sum_{n=0}^{\infty} n^2x^n + n^2\frac{x^n}{x} - nx^n - n\frac{x^n}{x} \\ \end{align*}  Any help is appreciated, thanks :) Cannot modify files installed by `snap` I have installed a package using snap and I need to modify one of the files but when I try to change its ownership or permissions, I always get the following message:  sudo chmod +x ./my_file.js chmod: changing permissions of '/snap/my_app/my_file.js': Read-only file system   How can I modify files that are installed via snap? Running two MySQL servers that use the same data directory