I am trying to perform a scan of the project containing the word stub for searching files in it. Files in UTF-16 encoding. However, when the parser comes to 1017 files, all with the error:     Exception in thread "main" java.lang.OutOfMemoryError: Java heap space.   How I can fix it?  import java.io.*; import java.util.Scanner;  public class FolderScanerV2 {      public static void FolderScaner(File file) throws Exception {         if (file.isDirectory()) {             File[] directory = file.listFiles();             for (File enter : directory) {                 if ((enter.isFile() &amp; enter.getCanonicalPath().contains("txt"))) {                     FileScaner(enter);                 } else {                     FolderScaner(enter);                 }             }         }     }      public static void FileScaner(File file) throws Exception {         BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsolutePath()), "UTF-16"));         Scanner text = new Scanner(in);         while (text.hasNext()) {             if(text.next().contains("Cap")) {                 System.out.println("Cap" + " " + file.getCanonicalPath());             }         }         text.close();         in.close();     }      public static void main(String[] args) {         String path = new String();         Scanner inpunt = new Scanner(System.in);         System.out.println("Input path");         path = inpunt.nextLine(); //           File dir = new File(path);         path.close();         try {             FolderScaner(dir);         } catch (Exception e) {             e.printStackTrace();         }     } }
I am writing a client-side Swing application (graphical font designer) on Java 5. Recently, I am running into java.lang.OutOfMemoryError: Java heap space error because I am not being conservative on memory usage. The user can open unlimited number of files, and the program keeps the opened objects in the memory. After a quick research I found  and others saying on Windows machine the JVM defaults max heap size as 64MB.  Given this situation, how should I deal with this constraint?  I could increase the max heap size using command line option to java, but that would require figuring out available RAM and writing some launching program or script. Besides, increasing to some finite max does not ultimately get rid of the issue.  I could rewrite some of my code to persist objects to file system frequently (using database is the same thing) to free up the memory. It could work, but it's probably a lot work too.  If you could point me to details of above ideas or some alternatives like automatic virtual memory, extending heap size dynamically, that will be great.
I am trying to design a circuit and was wondering how to design it that the 12V 800mAH NimH battery I am using will not overcharge. I have researched trickle charging and as far as I understand, a zener diode that regulates the voltage down to about 13.3-13.7V should do. I chose a 14V Zener, taking into account the .6-.7V drop.   I have heard that trickle charging is not the best for the battery, but am not sure how much more work designing a smart charger would take.  I was also thinking of using another diode to prevent flow back to the panels from the battery.         &ndash; Schematic created using  The three voltage sources on the left represent the solar cells, with the NiMH battery on the right.  I was wondering if I needed any additional components if I were to use three 5.5V solar cells in parallel outputting 40mA (16.5V total at 40mA, regulated to 13.3V by the zener) in order to prevent overcharging.  A similar question to mine was asked at  However, this dealt more with a larger lead-acid battery and used a voltage regulator with a schottky diode.   This link discusses almost my exact same question, but I was confused to the answer given which said that up to 1.45V per cell could be charged, taking my max charge voltage up to 14.5V.   Considering I am only outputting 40mA to an  800mAH battery, it seems that I may not need any more battery protection, but would love any input. Why does this Excel file keep asking to save? Prevent questions with movie/tv shows/game spoilers from appearing in the hot questions list I've noticed that occasionally "hot questions" from SciFi and the Movies &amp; TV network contain major spoilers about the movie/show discussed.  The Matrix spoilers:      (just now there's something about Cypher betraying Morpheus in the Matrix, which is a big deal for people who haven't seen the movie).   I like browsing through those but fear that one day one of these questions will spoil a show I'm excited about and yet to finish   Breaking Bad spoilers:      (like the finale of Breaking Bad, imagine a question asking why did one character betray another at the end or something).   Can users posting such questions be asked to label those with a tag (such as 'spoilers') and then somehow have the network hide those from the "hot questions" list? Or possibly format them differently?  Similarly, this could apply to the Arcade network too.  P.S. Love how this question spikes in popularity around the time GoT starts running again. I swear it should be fairly simple technically to ban questions that have a tag that says 'spoilers' from appearing in the Hot Network Questions.  P.P.S. Oh, and with every fresh release of Star Wars (The Last Jedi being the most recent one)!  P.P.P.S. Another year, another Game of Thrones, another spike in popularity! Why can't a Federation Starship's transporter history be used to bring someone back to life? How to prove $( A \times B ) \cap ( C \times D ) = ( A \cap C ) \times ( B \cap D )$ ? Chat messages should use consistent icon in iOS app It'd be nice if the chat notifications in the feed used the default Stack Exchange icon like the ones in the inbox do*:     Since items in the feed are grouped so that multiple items from the same site , the site icon helps delimit grouped items a bit less subtlely than the grey divider lines, and chat replies' lack of one causes them to sort of blend in to the previous group.  *Ideally it'd use the icon of the site the room was associated with, but I don't think that information is readily available Global Inbox -> Global RSS feed for all my questions across all the sites? I have the amulet of Mara but when I go to talk to maramal about a wedding nothing shows up. WHY is that. Shower at Heathrow during layover in Terminal 5 Reading the  questions here, I am not too hopeful, but this is the perfect site to find the answer if it does exist:  Facts:   I arrive at T5 (British Airways) at 08:30, depart at 11:40 from T5 (British Airways) to another country. No time once I reach final destination to shower, Leave straight from work to catch the first leg. US citizen + passport, only final destination visa (currently)   Desire:  I want to shower - 10 mins is plenty.  Assume money is no object (pay for lounge access, cabs etc), but I'd rather not buy full ticket if I can avoid it.  P.S. It's a wedding, so I REALLY want to shower before haha.  EDIT: My plan so far (which doesn't work because it's after Security):   Travel from  Use    UPDATE:  I followed G &amp; Doc's advice and walked over to the Sofitel Hotel (Immigration + walk ~20-25 min total) showered there for £25 and walked back through Security with plenty of time to spare.  Thank you all for your help! Word for a smart and stubborn person? I'm trying to find a single adjective that would fit the best to the following person's trait:     One who thinks knows everything/best, and often doesn't listen to orders and instead completes some task his/her own way.    This person, while intelligent, is right about 50% of the time, when doing things its own way.   So far I've thought of independent, idiosyncratic and stubborn, but these words don't imply the "knows everything/best" part of the trait. Intersection of two parabolae Problem: Consider two parabolae such that their axes of symmetry form a right angle. Prove that all four points of intersection lie on a common circle (it is an assumption that there exist such four points). Could you help me obtain a non-algebraic solution? (The algebraic one I did is given below.)  Algebraic solution:  There is a very simple algebraic approach, just introduce a Cartesian coordinate system such that the parabolae are given by equations:  $$y = \alpha_1 x^2 + \beta_1 $$ $$x = \alpha_2 y^2 + \beta_2 $$  and by scaling, adding and simplifying we can get the following ordinary circle equation (the right-hand side is positive because parabolae intersect): $$ \left(x-\frac{1}{2\alpha_2}\right)^2 + \left(y - \frac{1}{2\alpha_1}\right)^2 = \frac{-\beta_1}{\alpha_1} + \frac{-\beta_2}{\alpha_2} + \left(\frac{1}{2\alpha_1}\right)^2 + \left(\frac{1}{2\alpha_2}\right)^2$$  Non-algebraic solution: ?? The Time That 2 Masses Will Collide Due To Newtonian Gravity What does "T" mean in C#? I have a VB background and I'm converting to C# for my new job.  I'm also trying to get better at .NET in general.  I've seen the keyword "T" used a lot in samples people post.  What does the "T" mean in C#?  For example:  public class SomeBase&lt;T&gt; where T : SomeBase&lt;T&gt;, new()   What does T do? Why would I want to use it? Is there a way to have coloured hyperref hyperlinks in the PDF, but have them print "as if" they were black? I like having my hyperref hyperlinks a different colour, so it's obvious that they are links. But when I print a copy of the PDF, I don't want the links to be coloured, because you can't click them, so it doesn't matter and it's distracting.  Other than just having a separate "for printing" version of the PDF where I turn off the hyperlinks, is there a way to have the printed version come out without the coloured links? I quite often add a question as a favourite when there is something of interest to me in it or its answers. Looking back through my favourites, I cannot remember why I added some of them as a favourite.  What I'd like to be able to do is to add a note/comment when I add a favourite as a reminder as to why I've added it. This will show on my favourites page, but nowhere else - and possibly to no one else.  In addition, it would be good to be able to favourite an answer to a question, thereby adding a favourite to both the question and a particular answer with something of note in it. This would only show as a single favourite, but when clicking its link would go to the favourited answer.  Possible? Or is there another way of doing this? I've already got too many favourites to remember why I added a lot of them. This might be a stupid question, but nonetheless, it has been bothering me.  If you take a photon, make it go through some atoms in a solid, liquid or whatever, then you have the chance of this photon being absorbed by an electron, and thereby exciting the electron. This requires the photon to have enough energy to actually excite the electron to another energy level.  My question is then: How does the photon know if it has enough energy or not? Do they interact very quickly to determine if it's okay or not, or is it just something it "knows?" Existence of irreducible polynomials over finite field Let $F$ be a finite field. How do we prove that for each $n \in \mathbb{N}$ there is an irreducible polynomial of degree $n$?  One can assume that $F = \mathbb{F}_{p^m}$ where $p$ is prime. If $n \ge |F|$ then I can construct an irreducible polynomial, namely  $ p(x) = 1 + \prod_{j=1}^{|F|} ( x - a_j )$  where $a_j$ are all the field elements. It is clear that $p(x)$ has no roots in $F$.  This trick doesn't work for $n &lt; |F|$. A counter-example: Let $F = \mathbb{F}_3$ and $p(x) = 1 + (x-1)(x-2)$, then $p(1) = 1$, $p(2) = 1$, $p(0) = 1 + (-1)(-2) = 1 + 2 = 3 = 0 \pmod 3$.  I know there is a way to count them using the Möbius function $\mu(n)$ but I want a proof without it that just shows existence. How to Translate Content type name using i18n module? I am developing a multilingual site that supports English and Norsk bokmal. I have set English as my default language. I wanted to translate the contents and the other things in the site.  My real problem started when I found that I was unable to see the translation of the content type's name. I went to admin/config/regional/translate/translate and translated everything, but still my content type's name is not translated.  I have attached a screenshot of the translation page. Still I don't find a way to translate the content type's name. REST API composite query: How do I use the result of a query subrequest in the referenceId of another subrequest? I am using Salesforce's REST API to (1) retrieve a list of object IDs according to a query, then (2) retrieve the records that correlate to those IDs.  I am familiar with the Salesforce composite documentation .    My request looks like this:  POST: /services/data/v48.0/composite  {     "allOrNone":false,     "compositeRequest": [ {         "method":"GET",         "url": "/services/data/v48.0/query?q=SELECT+Id+FROM+My_Entity+WHERE+(CreatedById+!=+'asdfghjkl')",         "referenceId": "myEntity"         },{         "method":"GET",         "url": "/services/data/v48.0/composite/sobjects/My_Entity?ids=@{myEntity.records[0].Id}",         "referenceId":"myObject"     }] }   My response:  {     "compositeResponse" : [ {         "body" : {             "totalSize" : 21,             "done" : true,             "records" : [ {                 "attributes" : {                     "type" : "My_Entity",                     "url" : "/services/data/v48.0/sobjects/My_Entity/a0D6g000xxxxxxx"                 },                 "Id" : "a0D6g000xxxxxxx"                 }, {*record2*}, {*etc*}             ]},             "httpHeaders" : { },             "httpStatusCode" : 200,             "referenceId" : "myEntity"         }, {         "body" : [ {         "errorCode" : "PROCESSING_HALTED",         "message" : "'myEntity.records' references an invalid Datatype. Only Strings and primitive data types are allowed to be referenced from previous operations."         } ],         "httpHeaders" : { },         "httpStatusCode" : 400,         "referenceId" : "myObject"     } ] }   The first subrequest (the query) executes without errors.  My problem is the second subrequest.  I understand from  that I can refer to the ID of a single item (e.g. myEntity.records[0].Id).  Question: How do I use all items from myEntity.records in the second subrequest? Installation problem QGIS I do not manage to install QGIS on my windows 10 machine using the osgeo4w installer.  During the installation I get this message:   At the end of the installation I get this message:   And when I subsequently try to run QGIS, I receive this message:    Similar issue can be found in various fora, but none of them provides a conluding answer or did help me to solve the problem.  Any propositions?