Here is a far and away superior solution: use java.util.Properties
to handle your configuration file. Properties
supports a key=value
syntax that is very similar to the one you are trying to parse. It's up to you to decide whether that syntax is close enough to handle any existing configuration files you might have, and whether the validation and logging in your current code are essential.
CARVIEW |
Select Language
HTTP/2 200
date: Tue, 22 Jul 2025 23:35:58 GMT
content-type: text/html; charset=utf-8
cf-ray: 9636c1ecb840c195-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=84fecf18-b5e8-443d-b582-c435dd6b50f6; expires=Wed, 22 Jul 2026 23:35:58 GMT; domain=.stackexchange.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
x-frame-options: SAMEORIGIN
x-request-guid: e1ff5a03-ff42-4d0f-bb75-6f7755d15b23
x-worker-origin-response-time: 276000000
x-dns-prefetch-control: off
set-cookie: prov=84fecf18-b5e8-443d-b582-c435dd6b50f6; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=fnlWseurd8lW4tTRRLJr_E9dx32m2Mf6n668lwiigoM-1753227358-1.0.1.1-ajoo9ExOFYMGDHgeC0vJ9IFUUCCSq3y6TDfu1cDVWrJscHC4TbwjdJyzbffEVxzvv7t5oLSvZFbielRApIXCbyEp.UX5xmC.Qz_OBOqRa_k; path=/; expires=Wed, 23-Jul-25 00:05:58 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=oMnsJO2rGJ7vedoqRs82J7giMA5_pxXW0XskU5RIuIk-1753227358486-0.0.1.1-604800000; path=/; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
server: cloudflare
content-encoding: gzip
Revision - Code Review Stack Exchange
Skip to main content
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teamsdefault