Whitespace-problems in java properties file used to change language [duplicate]











up vote
-1
down vote

favorite













This question already has an answer here:




  • Java ResourceBundle leading whitespace in values

    2 answers




I need help with a java properties file that i am using to change the language of my program. The problem is: i want some of the strings in the properties-file to start with a space. however, java automatically trims the leading whitespace. Therefore whenever i am printing out some variable (like a chosen player name: John) followed by a line from the properties-file(won the game) it prints: ''Johnwon the game'', instead of ''John won the game.''



is it possible to avoid this?










share|improve this question













marked as duplicate by rghome, user7294900, Stephen C java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 14:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Post the code you tried.
    – forpas
    Nov 8 at 12:07










  • There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
    – prasad_
    Nov 8 at 12:15















up vote
-1
down vote

favorite













This question already has an answer here:




  • Java ResourceBundle leading whitespace in values

    2 answers




I need help with a java properties file that i am using to change the language of my program. The problem is: i want some of the strings in the properties-file to start with a space. however, java automatically trims the leading whitespace. Therefore whenever i am printing out some variable (like a chosen player name: John) followed by a line from the properties-file(won the game) it prints: ''Johnwon the game'', instead of ''John won the game.''



is it possible to avoid this?










share|improve this question













marked as duplicate by rghome, user7294900, Stephen C java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 14:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Post the code you tried.
    – forpas
    Nov 8 at 12:07










  • There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
    – prasad_
    Nov 8 at 12:15













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:




  • Java ResourceBundle leading whitespace in values

    2 answers




I need help with a java properties file that i am using to change the language of my program. The problem is: i want some of the strings in the properties-file to start with a space. however, java automatically trims the leading whitespace. Therefore whenever i am printing out some variable (like a chosen player name: John) followed by a line from the properties-file(won the game) it prints: ''Johnwon the game'', instead of ''John won the game.''



is it possible to avoid this?










share|improve this question














This question already has an answer here:




  • Java ResourceBundle leading whitespace in values

    2 answers




I need help with a java properties file that i am using to change the language of my program. The problem is: i want some of the strings in the properties-file to start with a space. however, java automatically trims the leading whitespace. Therefore whenever i am printing out some variable (like a chosen player name: John) followed by a line from the properties-file(won the game) it prints: ''Johnwon the game'', instead of ''John won the game.''



is it possible to avoid this?





This question already has an answer here:




  • Java ResourceBundle leading whitespace in values

    2 answers








java file properties internationalization properties-file






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 12:06









Asama Hayder

31




31




marked as duplicate by rghome, user7294900, Stephen C java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 14:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by rghome, user7294900, Stephen C java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 14:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    Post the code you tried.
    – forpas
    Nov 8 at 12:07










  • There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
    – prasad_
    Nov 8 at 12:15














  • 1




    Post the code you tried.
    – forpas
    Nov 8 at 12:07










  • There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
    – prasad_
    Nov 8 at 12:15








1




1




Post the code you tried.
– forpas
Nov 8 at 12:07




Post the code you tried.
– forpas
Nov 8 at 12:07












There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
– prasad_
Nov 8 at 12:15




There are few articles on the net if you search using a string like "java properties file whitespace". Here are some:reading-properties-file-with-spaced-value and reading-properties-file-with-space-null-escaping.
– prasad_
Nov 8 at 12:15












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










You can escape leading space like:



example =  won the game


However, it would be more conventional to hold the whole formatting string, like:



example = %s won the game





share|improve this answer





















  • This was just what i was looking for! Thanks dude :)
    – Asama Hayder
    Nov 8 at 14:30


















up vote
0
down vote














Is it possible to avoid this?




No, Leading whitespaces in a property value are automatically trimmed by Java, but trailing whitespaces are preserved. To workaround, you can simply modify your print statement.






share|improve this answer




























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    You can escape leading space like:



    example =  won the game


    However, it would be more conventional to hold the whole formatting string, like:



    example = %s won the game





    share|improve this answer





















    • This was just what i was looking for! Thanks dude :)
      – Asama Hayder
      Nov 8 at 14:30















    up vote
    0
    down vote



    accepted










    You can escape leading space like:



    example =  won the game


    However, it would be more conventional to hold the whole formatting string, like:



    example = %s won the game





    share|improve this answer





















    • This was just what i was looking for! Thanks dude :)
      – Asama Hayder
      Nov 8 at 14:30













    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    You can escape leading space like:



    example =  won the game


    However, it would be more conventional to hold the whole formatting string, like:



    example = %s won the game





    share|improve this answer












    You can escape leading space like:



    example =  won the game


    However, it would be more conventional to hold the whole formatting string, like:



    example = %s won the game






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 8 at 12:31









    Tim

    4,44612137




    4,44612137












    • This was just what i was looking for! Thanks dude :)
      – Asama Hayder
      Nov 8 at 14:30


















    • This was just what i was looking for! Thanks dude :)
      – Asama Hayder
      Nov 8 at 14:30
















    This was just what i was looking for! Thanks dude :)
    – Asama Hayder
    Nov 8 at 14:30




    This was just what i was looking for! Thanks dude :)
    – Asama Hayder
    Nov 8 at 14:30












    up vote
    0
    down vote














    Is it possible to avoid this?




    No, Leading whitespaces in a property value are automatically trimmed by Java, but trailing whitespaces are preserved. To workaround, you can simply modify your print statement.






    share|improve this answer

























      up vote
      0
      down vote














      Is it possible to avoid this?




      No, Leading whitespaces in a property value are automatically trimmed by Java, but trailing whitespaces are preserved. To workaround, you can simply modify your print statement.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote










        Is it possible to avoid this?




        No, Leading whitespaces in a property value are automatically trimmed by Java, but trailing whitespaces are preserved. To workaround, you can simply modify your print statement.






        share|improve this answer













        Is it possible to avoid this?




        No, Leading whitespaces in a property value are automatically trimmed by Java, but trailing whitespaces are preserved. To workaround, you can simply modify your print statement.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 12:24









        susan

        1




        1















            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?