I have a byte[] that I got through the wire and want to verify that it's a JPEG. How can this be done?  Essentially, without having to write out a file, I'd like to do, more-or-less, what the file command does:  $ file aoeu.jpeg aoeu.jpeg: JPEG image data, JFIF standard 1.02
How do you get a Media Type (MIME type) from a file using Java?  So far I've tried JMimeMagic &amp; Mime-Util. The first gave me memory exceptions, the second doesn't close its streams properly. How would you probe the file to determine its actual type (not merely based on the extension)?
I am using a linux server which has 128GB of memory and 24 cores. I use top to see how much it is used. Its output is pasted at the end of the post. Here are two questions:  (1) I see that each of the running processes occupies a very small percentage of memory (%MEM no more than 0.2%, and most just 0.0%), but how the total memory is almost used as in the fourth line of output ("Mem:  130766620k total, 130161072k used,   605548k free,   919300k buffers")? The sum of used percentage of memory over all processes seems unlikely to achieve almost 100%, doesn't it?  (2) how to understand the load average on the first line ("load average: 14.04, 14.02, 14.00")?   Thanks and regards!  Edit:  Thanks!  I also really like to hear some rough numbers based on used percentage of memory to determine if a server is heavily loaded, since I once became the one who cramed the server without understanding the current load.  Is swap regarded as almost the same as memory? For example, when memory and swap are almost of same size, if the memory is almost running out but the swap is still largely free, may I just view it as if the used percentage of memory + swap is still not high and run other new processes?  How would you consider together CPU or memory (or memory + swap) usage? Do you become worried if either of them reaches too high or both?  Output of top：  $ top    top - 12:45:33 up 19 days, 23:11, 18 users,  load average: 14.04, 14.02, 14.00 Tasks: 484 total,  12 running, 472 sleeping,   0 stopped,   0 zombie Cpu(s): 36.7%us, 19.7%sy,  0.0%ni, 43.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st Mem:  130766620k total, 130161072k used,   605548k free,   919300k buffers Swap: 63111312k total,   500556k used, 62610756k free, 124437752k cached    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  6529 sanchez   18  -2 1075m 219m  13m S  100  0.2  13760:23 MATLAB 13210 timothy   18  -2 48336  37m 1216 R  100  0.0   3:56.75 absurdity 13888 timothy   18  -2 48336  37m 1204 R  100  0.0   2:04.89 absurdity 14542 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.34 absurdity 14544 timothy   18  -2  2888 2076  400 R  100  0.0   1:06.14 gatherData  6183 sanchez   18  -2 1133m 195m  13m S  100  0.2  13676:04 MATLAB  6795 sanchez   18  -2 1079m 210m  13m S  100  0.2  13734:26 MATLAB 10178 timothy   18  -2 48336  37m 1204 R  100  0.0  11:33.93 absurdity  12438 timothy   18  -2 48336  37m 1216 R  100  0.0   5:38.17 absurdity 13661 timothy   18  -2 48336  37m 1216 R  100  0.0   2:44.13 absurdity 14098 timothy   18  -2 48336  37m 1204 R  100  0.0   1:58.31 absurdity 14335 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.93 absurdity 14765 timothy   18  -2 48336  37m 1196 R   99  0.0   0:32.57 absurdity 13445 timothy   18  -2 48336  37m 1216 R   99  0.0   3:01.37 absurdity 28990 root      20   0     0    0    0 S    2  0.0  65:50.21 pdflush 12141 tim       18  -2 19380 1660 1024 R    1  0.0   0:04.04 top  1240 root      15  -5     0    0    0 S    0  0.0  16:07.11 kjournald  9019 root      20   0  296m 4460 2616 S    0  0.0  82:19.51 kdm_greet     1 root      20   0  4028  728  592 S    0  0.0   0:03.11 init     2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd     3 root      RT  -5     0    0    0 S    0  0.0   0:01.01 migration/0     4 root      15  -5     0    0    0 S    0  0.0   0:08.13 ksoftirqd/0     5 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/0     6 root      RT  -5     0    0    0 S    0  0.0  17:27.31 migration/1     7 root      15  -5     0    0    0 S    0  0.0   0:01.21 ksoftirqd/1     8 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/1     9 root      RT  -5     0    0    0 S    0  0.0  10:02.56 migration/2    10 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/2    11 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/2    12 root      RT  -5     0    0    0 S    0  0.0   4:29.53 migration/3    13 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/3 Convert web page to image and is such interpretation the norm?  When something went from 4 units to 8 units, most authoritative sources seem to agree with the use of "a two-fold increase", even though what was actually increased is more like "one-fold", i.e. the original quantity.  But if the "two-fold increase" is the correct usage, why most people seem to interpret "a 100% increase" the same thing? Data from multiple lists using single REST API call Please help me to answer the following problem:  Let $f(x)=x^3-3x-5\in\mathbb{Q}[x]$  Thanks A finite summation of double binomial coefficients I find the following identity and have checked on Mathematica, while I have no idea how to prove it:  $$\sum_{j=0}^n(-1)^{n-j}\binom{p+j}{j}\binom{n+\beta}{n-j}=\binom{p-\beta}{n}, \quad \beta&gt;-1, \quad p&gt;\beta-1.$$  It seems that proof by induction does not work and because of the gamma function, the transform technique does not work either. Admin privileges requiring for installing a package build though Packages Using osx 10.9 and packages for making package installer.  While installing a package made using Packages in /Applications location on a osx 10.9 machine, installer is asking for Admin password. Even though I had unchecked 'Require admin password for installation' while package making.  So, how to avoid this i.e a non-admin user should install this package. Package should install in /Applications location, so that non-admin user can use the app.  I check  and why don't we define vector multiplication component-wise? I was just wondering why we don't ever define multiplication of vectors as individual component multiplication.  That is, why doesn't anybody ever define $\langle a_1,b_1 \rangle \cdot \langle a_2,b_2 \rangle$ to be $\langle a_1a_2, b_1b_2 \rangle$?  Is the resulting vector just not geometrically interesting? How can I find out what is using the hard disk? Possible Duplicates:             Once or twice a day my computer starts writing significantly hard to the hard drive, the HD led is ON and the performance hit is noticeable. A strange observation is that the Task Viewer does not show I/O activity - even Process Explorer shows no CPU activity and no I/O bytes read or written.  Is there a way to know which application is using the hard drive and how much data is it reading or writing? Setting custom UITableViewCells height group of units in a topological ring It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use m_foo. I've also seen myFoo occasionally.  C# (or possibly just .NET) seems to recommend using just an underscore, as in _foo. Is this allowed by the C++ standard? Batch files: How to read a file? How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode? Prove that if $a$ and $b$ are relatively prime, then $\gcd(a+b, a-b) = 1$ or $2$ Prove that if $a$ and $b$ are relatively prime, then $\gcd(a+b, a-b) = 1$ or $2$.  I started off by putting $\gcd(a+b, a-b) = d$. This implies that there are two relatively prime integers $x_1, x_2$, such that   $dx_1 = a+b$   $dx_2 = a -b$  Adding the first equation to the second gives us: $d(x_1 + x_2) = 2a$, and subtracting the second from the first gives us $d(x_1 - x_2) = 2b$. This implies that $d\mid2a, d\mid2b \implies \gcd(2a, 2b) = d \implies d = 2\cdot \gcd(a,b) \implies d = 2$.   This is based on the fact that $\gcd(x_1 + x_2, x_1 - x_2) = 1$, which is in fact the statement of the problem. How do I prove this? Can I somehow use the Euclidean Algorithm for this. How can Cooper communicate with his daughter before the time he went to space? How do I become a Werewolf? I've heard that one of (maybe the only?) secret races in this game is a werewolf.  How do I become a werewolf?  And by extension, how do I cure lycanthropy, that is, if there even is a cure? Why does the SARS-CoV2 virus not remain infectious forever? Or does it? Given that the majority of biologists do not currently consider viruses to be alive, a virus can never die.  It can, however, get destroyed by long exposures to soapy water, alcohol, and apparently certain frequencies of UV light.  Why is an individual SARS-CoV2 virion not infectious forever?  Or is it? How do I center a container in my HTML/CSS? Discrete mathematics - Find all integer solutions of the equation $a^2+ b^2 + c^2=a^2 b^2$. Find all integer solutions of the equation $a^2+ b^2 + c^2=a^2 b^2$.  This is one of the questions we presented in one session to contest preparation PUTNAM. It turns out that I can't get from the problem. Could someone just give me a hint? (Please, don't give me the answer. Simply, an argument that can help me advance in the problem or theorem might suffice.) How to convert java.util.Date to java.sql.Date? I am trying to use a  as input and then creating a query with it - so I need a .    I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me.