[Ejecución] java.io.FileNotFoundException: carácter extraño en Cadena

Jia Wei ぃ moo:

El símbolo extraño en el seguimiento de la pila:

El símbolo extraño en el seguimiento de la pila

StackTrace:

java.io.FileNotFoundException: E: estilename.png (El nombre de archivo, nombre de directorio o etiqueta del volumen sintaxis es incorrecta)

codificado-.java ANSI pretende cadena "E: \ test \ filename.png"

1) compilar ningún problema con la libreta abierta no ve el símbolo raro

terminar con toda tranquilidad

[Escribió Filereadapp.class] [691ms en total]

-JDK: 13.0.1, utilizar JavaFX y Apache Commons IO como módulo

utiliza ruta módulo, prolijo, añadir -options módulo

compilado con los comandos de archivo por lotes que se ejecutan, cd ... y javac ...

-Tuvimos visto el que algunos post sugieren que es trabajo de archivo victoria local de sys. o tal vez el trabajo JDK?

But I don't know how it works that changes the String itself. and how to fix it, prevent it?

2)StringBuilder->append all directory >append("e:").append("\test").append("\filename.png");

SB->String

FileOutputStream(Stringitself)

These are not the code itself!^ Just showing the flow of the real code.

Note on possible duplicate

I don't believe this is a duplicated post with any ?? char in Japanese word or anything.

Like file read/write using the relative path, as stated I gave absolute path unless the implementation of the absolute path is wrong.

Elliott Frisch :

In Java (and many other languages) \ is used to escape special characters (such as newline \n). Here you are escaping the letters t and f (\t is a tab and \f is a form-feed character) assuming your String looks like

String s = "e:\test\filename.png";

to fix that you can use any of

String s = "e:\\test\\filename.png";

or

String s = "e:/test/filename.png";

or

String s = "e:" + File.separator + "test" + File.separator + "filename.png";

Y estoy seguro de que hay algunas otras formas de escribir demasiado.

Supongo que te gusta

Origin http://10.200.1.11:23101/article/api/json?id=390028&siteId=1
Recomendado
Clasificación