|
You could create your own InputStream class that wraps the underlying socket stream, then just ignore the close-method call that the parser makes. This is actually not as bad of a hack as it sounds; you would be treating a part of the underlying stream as a stand-alone stream.
|
# ¿ Jun 7, 2009 11:33 |
|
|
# ¿ Apr 20, 2024 00:03 |
|
almostkorean posted:
The one called the operand stack holds temporary values. These are pushed on top of the stack by copying a value from somewhere and removed from the stack by popping a value, giving it to something else. The other one called a stack frame holds values that were used to invoke the current method and the values of any local variables. This is a 0-based array. In the simple case, where your code resides in a class method and width, height and im are arguments, the method call goes like this:
|
# ¿ Jun 24, 2009 21:52 |
|
My first guess would be that the TestClass.class file is in the root of the TestClass.jar and not in org/me/extension. If that's not the case, I'd start debugging by using a JarInputStream to make sure the .jar is good. Maybe compare to a known good .jar.
|
# ¿ Jul 24, 2009 15:23 |
|
It's most likely your code. For example, ArrayDeque.clear() is not likely to reduce the capacity of your aHugeFuckinArrayDeque, so if you're holding a reference to the objects somewhere else, calling it is not going to make any memory eligible for garbage-collection.
|
# ¿ Aug 3, 2009 22:21 |
|
That HTTP response looks a bit confused with that extra error document tacked on at the end. I'd make double sure that there are no subtle differences with the headers of the working and non-working requests. You can use Wireshark to listen in on the request Java is making. That should tell you which request headers you should tweak in Java to make it work.
|
# ¿ Aug 29, 2009 14:57 |
|
As in the OP's case the invalid URL is being used internally by Java, instead of switching to another HTTP library another option would be to use HttpURLConnection and handling the redirection manually. It's pretty easy: 1) Create the connection: (HttpURLConnection) new URL("http://somepath").openConnection() is guaranteed to work. 2) Disable redirection: .setInstanceFollowRedirects(false) 3) Check the response code: .getResponseCode() 4) Get and fix the real location: .getHeaderField("Location").replace(' ', '+') 5) Make a normal connection with the fixed URL.
|
# ¿ Aug 31, 2009 17:42 |
|
Use Collections.unmodifiableSet(set).
|
# ¿ Sep 1, 2009 16:57 |
|
tohveli posted:Well the Set thing was just an example. I have my own classes I pass, how do I make them unmodifiable? The same principle applies. You can wrap it in an unrelated class that provides a read-only view.
|
# ¿ Sep 1, 2009 22:44 |
|
fletcher posted:Any suggestions? Maybe it doesn't like a username that has a number in a wrong place. Generally, to narrow it down you'll want to do a binary search on your rows, i.e add rows 1-5000 or rows 5001-10000, then depending on which one is invalid split that range in two until you have the offending row.
|
# ¿ Sep 22, 2009 08:43 |
|
Knowing the line that throws the NPE would help, but you aren't checking against null in your second example, so I'd guess that's the culprit. E: The line numbers are printed in the exception stacktrace. Max Facetime fucked around with this message at 08:26 on Sep 24, 2009 |
# ¿ Sep 24, 2009 08:23 |
|
Short answer: when getting a byte representation of a String for transmission, you want to specify the encoding to use, in this case ASCII or UTF-8. Longer answer: Java Strings are stored in memory as a 2-byte Unicode variant codepoints, and the deal with data stream classes is that they closely mimic the memory storage. So those zeros are what's in memory. e: also, DataOutputStream writes the lengths of Strings so that a DataInputStream could read them back in, so you probably shouldn't use it unless there's a corresponding class reading it back in. Max Facetime fucked around with this message at 19:58 on Oct 19, 2009 |
# ¿ Oct 19, 2009 19:51 |
|
dis astranagant posted:Ugh, and I was told that DataOutputStream was the only way to send text and binaries over the same socket. JAVA It's a good way if you're transmitting between Java programs and don't mind using your own protocol. But interfacing with the rest of the world, it's better to use a dedicated library or low-level calls like String.getBytes(String charsetName) and OutputStream.write(byte[] bytes, int off, int len)
|
# ¿ Oct 19, 2009 20:27 |
|
geeves posted:Any thoughts? Am I blatantly missing something? I don't see relatedLinks being initialized, so it's probably null. Another thing is that arrays in Java do not expand after creation. Taken together, relatedLinks should be List<String> relatedLinks = new ArrayList<String>();
|
# ¿ Oct 21, 2009 19:15 |
|
yatagan posted:Do you think it's bad form to do this? No, Strings are immutable and while arrays are not, the responsibility for the array contents is clearly passed to the called method.
|
# ¿ Oct 23, 2009 09:16 |
|
fletcher posted:What's a good way of figuring out the difference between two calendar objects and offsetting another calendar object by that amount? Well, the simple and straightforward way is code:
|
# ¿ Oct 24, 2009 11:58 |
|
PT6A posted:Is there an easy way to create a Swing GUI (or part thereof) with overlapping components, but with as little absolute positioning as possible and greatest use of existing Swing widgets? Specifically, I'm working on a simple card game, and I want to have cards overlap nicely when displaying hands. I haven't used Swing much, but that doesn't sound like something Swing is intended for. Maybe use JavaFX for drawing the card game and Swing around it for GUI?
|
# ¿ Nov 7, 2009 17:15 |
|
LakeMalcom posted:For the random number/long guy: how about this: http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#BigInteger(int,%20java.util.Random) Do this, but use it to implement nextInt(int n) from earlier using BigIntegers. Using modulo to limit the random number range is a really bad idea. In short, if you have range and distribution ---- [0-3] doing a % 3 gives you: - --- [0-2] so number 0 is now twice as likely.
|
# ¿ Nov 23, 2009 13:52 |
|
Also http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#bitLength%28%29
|
# ¿ Nov 24, 2009 19:17 |
|
I haven't used HQL that much (I'm more either Criteria or native SQL kinda guy), but a little googling produced this. Basically your query should be "... where :column like :value" and have the %-characters in the parameter value itself. It probably has to do with how HQL is parsed.
|
# ¿ Jan 6, 2010 21:16 |
|
wigga please posted:
That looks like parameterised SQL. Having a parameterised column name like that is probably not supported on your database out of the box. Try it by hard-coding the column name before handing it over to Hibernate.
|
# ¿ Jan 7, 2010 17:41 |
|
I guess you could read directly from the console input by doing System.setIn(yourInputStream);
|
# ¿ Jan 23, 2010 11:57 |
|
Also, the solution 27^5 + 84^5 + 110^5 + 133^5 = 144^5 is a hint to the algorithm.
|
# ¿ Feb 2, 2010 18:55 |
|
Your hasNext() has two ways to check if there are more nodes after the current. You should choose one way and stick with that. How is hasNext() going to work on an empty list?
|
# ¿ Mar 7, 2010 12:24 |
|
epswing posted:
Yeah, don't do this mechanically. nextIsNull doesn't tell anything more than curr.getNext() == null. In this context, you could name them boolean isLastNode = curr.getNext() == null; boolean isFirstOrLastNode = curr.getData() == null; which gives return isFirstOrLastNode || isLastNode; which suggests there is a design problem.
|
# ¿ Mar 9, 2010 11:07 |
|
not a dinosaur posted:I have a list of integer message types that I want to map to strings. They will never change at runtime. I know about HashMap, but where is the idiomatic Java place to initialize it with all my poo poo Put it all in a text file, then access it using a ResourceBundle. No initialization required. If you really want to do it your way, then a static initializer block sounds about right. Max Facetime fucked around with this message at 17:25 on Mar 10, 2010 |
# ¿ Mar 10, 2010 17:15 |
|
ToastedZergling posted:tldr; I prefer leveraging existing frameworks than writing custom parsing I doubt there's such a thing, here are a couple of reasons: Yahoo! Mail: The best web-based email! .NET Rocks! - My .NET Story E*TRADE del.icio.us Mercedes-Benz Fake edit: good luck
|
# ¿ Mar 15, 2010 21:19 |
|
fletcher posted:Bump! This is driving me nuts! I looked at the cookie that is sent with Firebug. These keys have values: sessionid, __utma, aduserid, bbuserid, bbpassword and sessionhash. Try to catch them all from your browser and see if it works. It's hard to say why it works the first time without knowing the internals of the forums software.
|
# ¿ Mar 16, 2010 23:24 |
|
fletcher posted:Is there a way to check and see if anything has been written to a HttpServletResponse? isCommintted() may be what you're looking for in ServletResponse.
|
# ¿ Mar 26, 2010 17:04 |
|
You could wrap the original HttpServletResponse like this:code:
E: beaten!
|
# ¿ Mar 26, 2010 19:00 |
|
Is there a way to escape Expression Language results in a JSP file by default? I have ${item.value} in my JSP file, which generates the following code with Tomcat 6.0: code:
code:
|
# ¿ Apr 30, 2010 11:24 |
|
Yes. I could use c:out or roll my own, but I'd rather use ${item.value} for escaped text and <c:out value="${item.value}" escapeXml="false"/> for unescaped text. I've looked at replacing the Jasper compiler in Tomcat with a modified version, but I'd like to find an easier way.
|
# ¿ Apr 30, 2010 11:59 |
|
I'll give a hint about the culprit. If you redo the code above to use this brace stylecode:
|
# ¿ May 31, 2010 20:42 |
|
Flobbster posted:Telling him to switch to an inferior brace style is a terrible way of pointing him to his problem. Mmmmmm, just try it on for a couple of weeks, see if it fits. You can always go back real easily.
|
# ¿ May 31, 2010 21:24 |
|
korofrog posted:I've tried that style of braces and I personally don't like it. I like seeing my braces line up. My comment wasn't really about whether one brace style is better than another, rather it was the simplest step that would likely help you see the problem yourself.
|
# ¿ Jun 4, 2010 09:16 |
|
When compiling the first version my compiler stores null to the local variable even though the null value can never be read, resulting in a few bytes bigger method. Therefore the second version is more space-efficient. If I remove the null initialization, both versions compile to identical byte-code. If the method is called often enough to be JIT compiled, anything could happen.
|
# ¿ Jun 23, 2010 09:10 |
|
finally-blocks are meant for cleaning up resources. The trouble with streams is that the close-method is also responsible for committing changes made to the stream. In this case the GZIPOutputStream is probably doing some internal buffering, so the underlying ByteArrayOutputStream receives the data too late. To make sure this doesn't happen I usually structure my stream handling like this: code:
|
# ¿ Jun 28, 2010 00:49 |
|
Maybe it would work using a local workspace on the Windows machine, then Import...->Existing Projects into Workspace, point it to \My Dropbox and then tell it to not copy the project files to the workspace? I don't think putting the workspace itself to Dropbox is a good idea.
|
# ¿ Aug 22, 2010 02:25 |
|
Magicmat posted:You can see my horrible, messy, prototype-quality code here. You're not closing the connections or streams properly, so they might be closed only when the program terminates. This could affect the order and timestamps of the log entries the webserver outputs. Also, try adding a 10 second delay between testing different proxies to see whether the duplicate log entries come from the same or different proxies.
|
# ¿ Aug 24, 2010 07:26 |
|
OddObserver posted:Any chance for a link on that? Can't seem to find it on the Sun^wOracle website. It's called Project Coin. The proposal looks like to add a list of suppressed exceptions to Throwable, which deals neatly with the case where closing a resource throws an exception while another exception has already been thrown.
|
# ¿ Aug 26, 2010 17:27 |
|
|
# ¿ Apr 20, 2024 00:03 |
|
BigInteger has also a remainder method, which is defined in terms of the %-operator.
|
# ¿ Sep 8, 2010 12:29 |