How can we read data from a text file and store in a String variable?  is it possible to pass the filename in a method and it would return the String  which is the text from the file.  What kind of utilities do I have to import? A list of statements will be great.
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();     } }
Comparing and contrasting, p-values, significance levels and type I error I was wondering if anybody could give a concise rundown as to the definitions and uses of p-values, significance level and type I error.  I understand that p-values are defined as "the probability of obtaining a test statistic at least as extreme as the one we actually observed", while a significance level is just an arbitrary cutoff value to gauge if the p-value is significant or not. Type I error is the error of rejected a null hypothesis that was true. However, I am unsure regarding the difference between significance level and the type I error, are they not the same concept?  For example, assume a very simple experiment where I flip a coin 1000 times and count the number of times it lands on 'heads'. My null hypothesis, H0, is that heads = 500 (unbiased coin). I then set my significance level at alpha = 0.05.  I flip the coin 1000 times and then I calculate the p-value, if the p-value is > 0.05 then I fail to reject the null hypothesis and if the p-value is &lt; 0.05 then I reject the null hypothesis.  Now if I did this experiment repeatedly, each time calculating the p-value and either rejecting or failing to reject the null hypothesis and keeping a count of how many I rejected/failed to reject, then I would end up rejecting 5% of null hypotheses which were in actuality true, is that correct? This is the definition of type I error. Therefore, the significance level in Fisher significance testing is essentially the type I error from Neyman-Pearson hypothesis testing if you performed repeated experiments.  Now as for p-values, if I had gotten a p-value of 0.06 from my last experiment and I did multiple experiments and counted all the ones that I got a p-value from 0 to 0.06, then would I also not have a 6% chance of rejecting a true null hypothesis? Rest mass of the photon Why is the rest mass of the photon is taken to be zero?  If rest mass of the photon is non zero, then it leads to infinite energy of the photon (by $E=mc^2$ equation) and there is a violation of conservation of energy. Is this a reason?  Also, is there any thing called the relativistic mass of the photon? Exception thrown inside catch block - will it be caught again? This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below?  try {   // Do something } catch(IOException e) {   throw new ApplicationException("Problem connecting to server"); } catch(Exception e) {   // Will the ApplicationException be caught here? }   I always thought the answer would be no, but now I have some odd behaviour that could be caused by this. The answer is probably the same for most languages but I'm working in Java. Arrows linking table cells I'm currently trying to add arrows in my synthetic division example to show people clearly how synthetic division works. I'm working on Overleaf.   The code for my synthetic division right now is:  \begin{tabular}{c |r r r r r}     &amp;1&amp; 4 &amp; -1&amp;16&amp;-20\\   1&amp;&amp; 1 &amp; 5 &amp; 4&amp;20\\   \hline    &amp;1 &amp;5 &amp; 4 &amp; 20 &amp;\rule{3pt}{16pt}\;0\\   \end{tabular}   How would I add arrows to this? For instance, a down arrow going from the first 1 to 1, then an upwards arrow pointing right from 1 to 1, then an arrow pointing down from 1 to 5, etc. Basically I would like to add arrows that look like this: How do we prove $\cos(\pi/5) - \cos(2\pi/5) = 0.5$ ?. Why can't I do this to get infinite energy? As an example I have a BSB file from NOAA which is a navigational map. The map has a SRS of WGS84 and a Mercator projection.  I initially translate the file from BSB format to GTiff format using the following command:  gdal_translate -of GTiff 18554_1.kap noaa.tif  I can view this GTiff file using Paint Shop Pro quite fine. I then translate the file from GTiff format to VRT format using the following command:  gdal_translate -of vrt –expand rgba noaa.tif noaa.vrt  I then try to generate a tile matrix set using the following command:  gdal2tiles.py noaa.vrt tiles_folder  Where the map tiles are located in tiles_folder. If I try to open the openmaps.html or google.html, the map zoom in and out looks good. However, on tiles generator like MBTiles, I see tiles swap. See the image below. I am pulling my hair off to get the tiles to line up. I am guessing it is projection error. I am not understanding those projection types. It would great someone can explain it while finding the error. I am planning to use on a tiling  like this. By the way, on GDAL how do I specify the BSB (reference) file that is associated with KAP (data) file? I have seen cases where only one BSB file referred by multiple KAP files. Laptop using 14.04 won't get past login GUI When trying to add a bit more detail to a related , I realized I don't know how to specify which one of the available Bash word types to execute. According to help type there are five word types:   alias keyword function builtin file   It's possible for a word to have several types (true is just an example; a more commonly overridden word would be cd):  $ type -a true true is a shell builtin true is /bin/true   How do you force the execution of a specific synonym? So far, in order of precedence:   alias: This is a special case since it has precedence over all the other synonyms. Forcing this would only be useful when the command should fail if the alias is not defined.  $   keyword:  $   function:  $   builtin:  $ builtin true  file:  $ command true $ $(which true) $ /bin/true    :   Quoting a word excludes aliases and keywords. That is,  $ 'true'   will run only the function, builtin or file. To get the character sequences of a particular keyboard shortcut we use showkey -a or verbatim insert (Ctrl+V). What is the opposite of it? How can I get the keyboard shortcut in human readable format from character sequences? I used some keybindings for example ^[^? ^X^U ^[[3;5~ ^[[1;2D ^[[1;2C ^[[1;5C ^[[1;5D ^[[1;6C ^[[1;6D ....  Now I do not remember which key/key-combination they used to represent. How can I find that out? Update 1 I am looking for something which will output Ctrl+R or Ctrl+Delete etc, I mean in human readable format. Any reference to a table which has possible character sequences and their human readable formats will also do. Software center not loading software lists How to stop Mathematica 12.1 from chopping off the axes arrows? The keyboard I am trying to create has a lot of Unicode and looks like this:   Being unsuccessful with the following tutorial:    (There are a few errors in the tutorial, and it uses imprecise language such as "Cutting" things instead of "Deleting" them, and it is formatted strangely)   I was wondering if anybody would be so kind to provide a better tutorial with step by step instructions? Most people spend part of each day standing, and if they have normal anatomy their heads are over their heels in this position.  Even sitting or lying down, the head is higher than the heels (if not over the heels).  Yet the phrase "head over heels" is used in ways implying it is an unusual situation.  How did such usage come to be, and why does it persist?  Why is the more obvious "heels over head" not used? What do you call a person who does/thinks the opposite of the crowd for just that reason? Such a person does not hold in high regard the decisions taken by a group (not a team) of people. She believes that groups tend to be anarchic and don't serve their purpose.  An example would be - for outings with friends, this person will not like planning it with the group since they will mess it up.  Therefore, this person has convinced herself that when more people are involved with something, it will be worse. She distrusts crowds instinctively basically. Mathematics for Quantum Mechanics What math should I study if I want to get a basic understanding of quantum mechanics and especially to be able to use the Schrodinger's equation. As a moderator, how do I handle a potentially inappropriate profile picture? Change the URL in the browser without loading the new page using JavaScript smallest number for given sum of digits Where can the viewport clipping parameters be changed?