java - when debugging, if i have some writer, how can i get the file name+path it is writing to?

StackOverflow https://stackoverflow.com/questions/15119425

  •  15-03-2022
  •  | 
  •  

Pregunta

When debugging, i'd like to, having come across a Writer, be able to tell where it is writing to.

A cursory inspection of the object yields little to work with on the file name/file path front.

Is there some way - either a method i can call on said Writer, or some field that i can inspect - that will let me know which file the Writer writes to?

¿Fue útil?

Solución

On Linux, if you can dig down to a file descriptor number, you can examine /proc/pid/fd/fdnum to see what file or socket it references.

On Windows, if you can dig down to a file handle, you can use a tool like Sys Internals Process Explorer to trace the handle to a physical file.

On a Darwin/BSD system you would use opensnoop.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top