This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!

Matt Wong

Ranch Hand
+ Follow
since Aug 18, 2017
Matt likes ...
MS IE Notepad Suse
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Wong

the questions is not unique defined - are you try to look for any matches or do you want all entries the same (i cant come up with a usefull case for the latter one)?

also: why get(z++).equals(get(z--))?
simple write: get(z).equals(get(z+1))

if you really want to all entries the same: for(Integer integer : list) ...
this way you make use of List.iterator() - depend on impl of list may faster
4 days ago
well, whenever someone comes up with question about some topic involving memory limitations (mostly these questions are like "I need to increase upper max memory limit") I reply mostly the same: Do you really need all of the data in memory at the same time?

Your object is no different to me: you're limited to 300kb chunks - where's the problem?

Base64 is well known: it takes in 3 8-bit bytes and returns them back as 4 6-bit bytes encoded using a defined map - or vise-versa when de-coding.

If chunked processing you can do it as little as this one step or as many as your resource limit allows/requires. Only thing you should consider is to work in multiple of whole blocks, otherwise its a bit more complicated when tryin byte- or bit-wise (that means: when encode read 3 bytes and output 4, when decode read 4 bytes and oupt 3)

4 days ago
well - don't even think about DES - it's broken and can be bruteforced by any modern system
also - even DES-ede (as it's called correctly) - or triple-DES - is supposed to use 3 different keys and so bump up to 168bits - but in real world DES-ede only uses two keys - and therefore is only 112 bits (you can read about that on wikipedia)
so - IF you want to encrypt something - use AES - and at least something secure as CBC or OFB or so - never ECB (also: wikipedia)

i still don't understand what you try to protect - the main issue here is that you allow some secret information to get outside your controlled environment - why you even allow this? this is already flawed by design

if you want to export some secret information - use PBE and always ask the user

as others said: the only time you store keys unencrypted is on a secured server wich provides security at os-level - cause when someone has access to the system - it's easy to get admin/root access - and then you lost anyway
6 days ago
the main reason i decompiled and look through your code was
1) never run code you dont know or trust
2) check to see if it does something odd
3) i already ran into some copy'n'paste trick cause someone has hidden the code outside the sites layout and i didnt noticed it in my editor
i jsut found these "wtf" lines by simple scrolling through it scanning it for some unwated lines
6 days ago
well - i did came up with a possible thing: java.sql.Driver
since java7 the method Logger getParentLogger was added
when we now implement such driver and use override annotation - everything j7 and up will compile it just fine - even when we told it to do so for j6 or earlier - cause the compiler doesn't know the v6 version of this interface

the other way around: when you have a really old driver compiled back with j6 - it doesn't comply to v7 interface as it doesn't have getParentLogger method - wich would lead to some error at classloading time - or if the class somehow can be loaded it would fail when someone tries to call this very method
6 days ago
this very warning comes up when you compile for some older version with a newer jdk
as far as i know it means some those lines: i compiled it for the requested lower version based on my current knowledge - but can't verify if it will really work with the requested version

basicly - the compiler warns that it somehow manged to compile what you told it to - but it can't verify that it will actually run correctly on the request lower version because it doesn't have access to that very version but only to its own
the compiler is smart enough to know its own version and complains if you request to do a job for a different lower one

I can't come up with an example - but I guess someone had some in mind when this was added - maybe the JLS could get some hint - allthough this is more like a compiler thing than java specific as a language itself
6 days ago
java is copy by value - this means, when you call your method you query the current value of the autoboxed bool and copy this very value as the parameter - so your observation is correct: the posted lines doesn't change this value anywhere

also: don't use 'bool == true/false' as this is error prone
better use this: 'bool' or '!bool' and try to design the overall logic in a way that you mostly only check if a bool is true - you're checking for some that is not true - try to rethink if you can rephrase the check so it becomes a test if something is true
this way you can greatly increase readability and understandability
1 week ago
ok - so I de-compiled you code - found this:

even if it's only running on localhost - at least run mysql_secure_installation and set a root password
further: you can remove any line of this

mysql driver is JDBC4 complient - this means, as long as its in classpath it registers itself with serviceloader - no need for Class.forName()
current driver is v8 - wich is com.mysql.cj.jdbc.Driver - the v5 you use is obsolete
you wasting lots of database resources - as you open a new connection on every request - but never proper close them - that's not how to do - if you want to use a sql-database you create ONE and only ONE connection at startup and close it cleanly at exit - also each resultset and statement has to be close as long as you don't use try-with-resources wich uses autoclose

i dont know lic4j - but is it right that some master-key is in source?

from DNSSEC i know 03 010001 is for 65537 - but this SHA512withECDSA cofuses me - what strange kind of format is this?

overall - very advanced project with beginner mistakes somewhat not matching the question
1 week ago
"downloading an e-mail" is in fact as easy as it sounds
no matter what it contains, at least is still the same old plain-text protocol it was 20 years ago
so an e-mail is nothing else then a long text-file with additional headers included
binary data gets encoded with Base64 - and as long noone defines 8-bit-transport-encoding - all you have to deal is with standard 7-bit ascii - as e-mails defined as such
it's up to the user agent how to display or otherwise handle the mail

also: javamail is more a end-user lib for mail user agents as some mid-tier code just copying bytes around when used the way you want to

better approach: your client uses e-mail the way s/he should: setup a mta for the domain and use one of the standard complient mail programms *hint*thunderbird*hint*personal choice*hint*
or one set up a mail forwarder proxy - but goin javamail - doesn't seem fit
1 week ago
well - you can either ask the user for a pbe phrase - or store the data in plain
reason: as long as you try to hide somethin you have to reverse it - and when your code can anyone else can
thats called security by obscurity and is always a bad idea
1 week ago
That's pretty easy one when read carefully: you build your project ontop java 10 - but the server only supports up to EE7. And we all should know what happens when one try to run code compiled by newer compiler to run on older vm: version-error - as java is only backwards compatible.

So, either setup a server matching your build environment - or fix your build to match highest supported server version.
1 week ago
i know that some of the mods maybe not so cool with this reply, but most topics wich title is "why is X the way it is and not Y?" and repeat that question in the post can be answered with: "because someone decided so" or "cause it has to / can't be Y"

so to come back to the main question, why long literals have to have trailing L and why the otherwise seen as int: because someone in the past decided so - just take it as given instead of try to argue about it - you can't change it anyway (well, for most of those questions)
3 weeks ago
also +1 for not only reporting back that you solved but also that you included what was wrong and how you fixed it
you should have an option to mark this topic solved - so others could see that the question was answered before have to read through all
glad you could figured it out
3 weeks ago
for compiler errors, please post the full message inside a code block so the format is kept
cannot find symbol can mean many things without the information, wich symbol wasnt found
code looks ok so far from first looking
3 weeks ago

Tim Holloway wrote:

Junilu Lacar wrote:

Rinu Gour wrote:The & operator is applied to the operand when both the boolean and && operator is evaluated. Once an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator in Java is then applied to the first and second operands. If the first operand evaluates to false, the analysis of the second operand is skipped.

No, that is an inaccurate description.

A more accurate description is that the sub-expression to the left of the && is evaluated and IF FALSE, the right-hand sub-expression is bypassed (short-circuited) and the operation returns false. IF AND ONLY IF the left-hand subexpression evaluates to true, THEN the right-hand subexpression will be evaluated and the operation will return true or false depending on which value the right-hand subxpression returned. This has side effects. If the right-hand subexpression includes one or more method calls, then the calls will not be made if the short-circuit is taken. Nor will prefix/postfix increments and decrements (such as i++) be performed.

The "&" operator technically has two meanings. One is the simple boolean operator, where both left and right sub-expressions are boolean expressions. In that case, the logical AND value for the results of the two sub-expressions will be returned as a logical value.

The other meaning of "&" is as a BITWISE operation, where the binary value on the left-hand side is AND'ed to the binary value on the right-hand side bit by bit. For example, 0110 & 1100 results in 0100.

Some might argue that the boolean & is simply the same thing as bitwise & for a pair of one-bit values, but that's assuming internal implementation details and Java is more abstract than that.

To be even more correct: There is no second meaning on '&' but only one: bitwise and - the reason why it leads to eval of both terms is simple as it's needed to calc the output - as booleans mostly repesented as at least byte or bigger type (most likely native datatype) wich limited to can hold only 0 and 1.

The effect here is: to calc the correct awnser both terms has to be eval down to two 1-bit numbers. There is no such thing as "'&' has the meaning of 'logical and'" as there is no 'logical and' in java - there're only & and &&.
1 month ago