S Lei

Greenhorn
+ Follow
since Feb 20, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S Lei

Mh. Yes, I think that would be the solution, to just let it do it's job . I only thought, that it might be a good idea sind I heard a speech about it long ago, in which the garbage collection jsut seemed to cleanup in regular time-periods.

Kind Regards,
Simon Leischnig
10 years ago
Hello,
Nearly every time I used the gc() method in the Runtime object, I was noticing, that it actually seemed to consume a few megabytes of my available memory. I used the method directly after heavy-duty image operations where I disposed all objects and nulled the database. I don't know why this happens, any ideas?

Thanks =)
10 years ago
Great Thanks. I solved it with generic types, too in the meanwhile. Although, I missed the last hint, too, and now everything feels right.
11 years ago
Hello,
I recently encountered the following problem: I got an abstract class, A, and several (non-abstract) subclasses of A: X, Y, ...
I want to make sure all subclasses of A (name: Z extends A) can calculate distances between each other. In other words: Each subclass Z has to have a method "double distanceTo(Z)". Now, I can't find a way to ensure this. Can you help me out, explain me why it is not possible, or give me a hint what can be done instead?

Thanks!
11 years ago
Hello,
I'm working on a project these days, where I'm not responsible for the framework I have to work within. Now, ther are some problems with the encoding and special characters:

I've got to process text from an InputStream, and return an InputStream itself again. For this processing, I need the complete String from the given InputStream. Furthermore, I have to assume that the text in the InputStream contains every sort of characters, special characters and such. I assume, that the content of the InputStream is UTF-8 encoded.
Now, my first question is: Is this even possible? As far as I read, InputStreams work with bytes and byteArrays. byte can only take the values from -128 to 127, no? So, how can UTF-8 text be stored in an InputStream?

Now, assuming the answer to the question above is "yes" - I read the text from the Stream with an InputStreamReader, and I'm processing some form of output, as String.
How can I create an InputStream that contains the output, and ensure UTF-8 compatibility? Until now, I just found a possibility with ByteArrayInputStream, but they say it's deprecated, and I have to use a StringReader. But how can I convert/transform a StringReader into an InputStream?

-- PS: 1) Sorry for this post in the first place -- I had a total blackout and postet it in my mother language ^^
2) ByteArrayInputstream seems to work - but they say, that there is a more preferable way with StringReader. Mh.

Thanks in Advance!
Simon
11 years ago
Sorry, I didn't knew this is discouraged. Will continue to ask on the other board :/
11 years ago
Hello,
I hope you know the answer to my beginner question -- I have a JButton, which has an Image drawn to it. Now I tried to apply a Layout to this Button and the whole rest of my formular, and this works fairly good. The Button is resizing when I resize the Window. But I wish to make the Image on the Button smaller, when the Button shrinks, and bigger, when the button gets bigger. Is there any possibility to do this without too much hassle? Is there an autofit setting, or another way to get notified anytime the button gets resized?
When there is such a notification: How do I get the size the button is tried to be resized to? Just with getSize()?
And talking about "best practice" -- yea, what would the best practice be here?

I hope this question doesn't annoy you too much; I am a total GUI beginner :/
Thank you very much!

Simon L.
11 years ago