KITFORMA · EDITORIAL ANSWER
Why does a command read from a file fail a Java string comparison?
KitForma editorial guide. A literal and decoded input can contain the same characters without being the same object. First distinguish reference identity from content and then investigate the input bytes.
Step-by-step answer
"EXPORT".equals(command) for a null-safe exact command. If the protocol allows surrounding whitespace, normalize that explicitly before comparing; do not blindly remove meaningful spaces from passwords or identifiers. Inspect a redacted length or character-code fixture to discover a trailing newline or byte-order mark instead of logging production input.
Test a literal, a newly constructed equal string, mixed case and trailing whitespace. Case-insensitive comparison is a separate protocol decision. Content equality does not normalize visually similar Unicode sequences or remove hidden characters.Sources and verification
Sources checked:
This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.