java - Why is my getString() method always returning null? -



java - Why is my getString() method always returning null? -

i have problem file lookup function made yesterday, method used homecoming file, returning null changed homecoming file path, still returning null when it's not, here's code , output:

public static string lookupfile(file file, string name) { file[] list = file.listfiles(); if(list != null) { (file fil : list) { string n = fil.getname().replace(name, ""); if (n.length() != 0) { if(fil.isdirectory()) lookupfile(fil , name); } else if (n.length() == 0) { string g = fil.topath().tostring(); system.out.println(fil.getname()); system.out.println(g); homecoming g; } } } homecoming null; }

the way i'm using so:

string n = sys.lookupfile(new file(sys.getappdata() + "g/"), "ggf.rtf"); system.out.println(n);

the output this:

ggf.rtf c:\users\name\appdata\roaming\g\h - re-create (5) - copy\h - re-create (5)\ggf.rtf null

why turning null after it's been returned ? before returning string, prints out, , can see it's not null what's wrong ?

the null getting in console returned result lookupfile() (the code gets final return null statement). debug method , see why happens, go through if/else conditions.

java string null return-value

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -