Question

File outputFile = new File(path, clickedKey+".txt");
OutputStream fos = new FileOutputStream(outputFile);
fos.write(data.getBytes());
fos.close();

This piece of code works when a path doesn't contain chars like: "ąóźżę" (special characters from polish language). If the path contains any of them fos.write works but there's no effect (new file isn't created with "foreign" path name, but the path exists). My question is: what can I do to fix it?

File managers apps like "Astro", "File Manager" etc. work without any trouble with such characters.

I try also this:

Charset charset = Charset.forName("UTF-8");
CharsetEncoder encoder = charset.newEncoder();
CharsetDecoder decoder = charset.newDecoder();

ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(clickedKey+".txt"));
CharBuffer cbuf = decoder.decode(bbuf);
String s = cbuf.toString();

bbuf = encoder.encode(CharBuffer.wrap(path));
cbuf = decoder.decode(bbuf);
String path_s = cbuf.toString();

File outputFile = new File(path_s, s);
OutputStream fos = new FileOutputStream(outputFile);
fos.write(tab.getBytes());
fos.close();

but it doesn't work as well.

Was it helpful?

Solution

When my phone was connected by ADB and I was checking new files with DDMS, there wasn't any file on "foreign" path. But in fact, files were in phone!

I checked it, with file manager direct in my phone :) It strange. But I solved the problem.

OTHER TIPS

Did you check the encoding? in eclipse: Edit > set Encoding > utf-8 or 16

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top