java - Powershell outputting malformed filenames -
i'm using command:
get-childitem | foreach-object {$_.basename} > file_names.txt
to print file names in current directory file (without final extensions). opening file names in notepad shows file names printed. simple enough, yes. cool.
my problem on reading file names in bufferedreader in java, file names coming malformed. example,
20100916_090350_s1_1_auto gain test_1.rad comes
ÿþ2 0 1 0 0 9 1 6 _ s 1 _ 1 _ u t o g n t e s t _ 1 . r d
(the .rad extension should there, there extension after wanted removed)
i assume type of silly windows encoding issue. unfortunately, know nothing these sorts of things. on appreciated.
thanks
powershell default emits unicode, , characters see @ beginning called bom (byte order mark). can either force java read unicode, or force powershell output other encoding, preferrably default
or oem
of out-file
parameter -encoding
. summarize try this:
get-childitem | foreach-object {$_.basename} | out-file -encoding default file_names.txt
Comments
Post a Comment