0

I have a tiny method attempting to return a Windows file path from an InputStream object. In the Eclipse Variables window, I can see the String I want in the field 'path', but can't seem to access and return it. (See image.)

static String getPathFromInputStream(InputStream is) {
    Scanner s = new Scanner(is).useDelimiter("\\A");
    return  "abc";     // Compile error from:  is.in.path;
}                      //  "in cannot be resolved or is not a field"

Two questions: Should I be able to access everything I see in the Variables window? And two, how do I return String 'path' (if I can)?

Eclipse Variables window

enter image description here

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
KeyLawson
  • 1
  • 4
  • As indicated by the answer to the duplicate question, it's not possible in general. However, there are ways around it if you are willing to accept some limitations. – E-Riz Apr 22 '16 at 19:58
  • I can't answer this question since it was closed, but I added my own detailed answer to the other: http://stackoverflow.com/a/36802489/639520 – E-Riz Apr 22 '16 at 20:13

2 Answers2

1

Your input stream object is of type FileInputStream but represented as InputStream, that property is for FileInpuStream.

And no you can't access all variables in that window, it's showing you all private and public variables, you can only access public members and methods.

Shirin Safaeian
  • 950
  • 6
  • 18
0

Well, the answer is: no, you are not supposed to get a path from the InputStream. The variable you are seeing is supposedly private, and as for the in field, there is a protected in field in filtered streams based on FilterInputStream, I believe.

Michał Zegan
  • 456
  • 4
  • 12