else if issues java -



else if issues java -

i have else if loop, loop searches through file extension see if matches, if not want print out message, have tried print , println, never prints out message, ideas doing wrong, apart loop working fine

if (extension.equals("txt")) { psinformat = docflavor.input_stream.autosense; } else if (extension.equals("jpeg")) { psinformat = docflavor.input_stream.jpeg; } else if (extension.equals("png")) { psinformat = docflavor.input_stream.png; } else if (extension.equals("gif")) { psinformat = docflavor.input_stream.gif; } else if (extension.equals("pdf")) { psinformat = docflavor.input_stream.pdf; } else if (extension.equals("html")) { psinformat = docflavor.input_stream.text_html_host; } else { system.out.print ("sorry printer no back upwards file type, sorry") ; }

there nil wrong code, can check following

extension string i.e. default equals() implementation you provide extension other txt,jpeg,png,gif,pdf , html, message can printed

you improve doing comparing blew avoid possible nullpointerexception , case sensitive comparisons

if("txt".equalsignorecase(extension)){ //... }

finally can seek print debug statement outside status , see if can see correctly in console

java

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -