Getting "java.nio.charset.UnmappableCharacterException: Input length = 1" -
i getting unmappablecharacterexception on collect() method call (or on tolist() call):
private static void handletransaction(path a_filepath, string a_strasactionname, string a_stransactionfilepath) { // read file stream, try-with-resources try (stream<string> stream = files.lines(paths.get(a_filepath.tostring()), charset.defaultcharset())) { list<string> list = stream.filter(line -> (line.indexof(a_strasactionname) > 0)) .collect(collectors.tolist()); list.foreach(line -> { system.out.println(line); try (bufferedwriter writer = files.newbufferedwriter(paths.get(_files_path + a_stransactionfilepath),charset.defaultcharset(), standardopenoption.append)) { writer.write(line + "\n"); } catch (ioexception e) { e.printstacktrace(); } }); } catch (ioexception e1) { e1.printstacktrace(); }
it worked me once, never since then.
the files read csv files created on solaris. run jar on windows 2012 server
can advise please?
thank you.
the files read csv files created on solaris. run jar on windows 2012 server
well that's problem then. you're using platform-default encoding both reading , writing file. if files created on solaris, may have different platform-default encoding windows box.
if know encoding of file you're reading, specify that.
if control encoding of file you're reading , writing, recommend using utf-8 unless have reason not to.
only use charset.default()
if you're reading file know uses platform-default encoding, or if you're writing file want use platform-default encoding - , try avoid latter.
(basically, world encoded in utf-8 simpler world...)
Comments
Post a Comment