Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - return type of the variable

return type of the variable

Put your problem here if it does not fit any of the other categories.

return type of the variable

Postby amatorIP » Sat Feb 04, 2012 1:04 pm

Hi All!
Please help! Which return type I need in follow function?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public static Node getDoc(String wayToFile){
  2.                 /*Create a DOM Parser*/
  3.                 try {
  4.                         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  5.                         DocumentBuilder builder = factory.newDocumentBuilder();
  6.                         Document document = builder.parse(new FileInputStream(wayToFile));
  7.                         Node root = document.getDocumentElement();
  8.                                                
  9.                 /*handle exception creating DocumentBuilder*/
  10.                 } catch(ParserConfigurationException parserError){
  11.                         Log.e(TAG, "Parser Configuration Error");
  12.                         parserError.printStackTrace();
  13.                 }
  14.                 /*handle exception reading data from file*/
  15.                 catch (IOException fileException){
  16.                         Log.e(TAG, "File IO Error");
  17.                         fileException.printStackTrace();
  18.                 }
  19.                 /*handle exception parsing XML*/
  20.                 catch(SAXException parceException) {
  21.                         Log.e(TAG, "Error Parsing Document");
  22.                         parceException.printStackTrace();
  23.                 }
  24.                 return root;
Parsed in 0.012 seconds, using GeSHi 1.0.8.4

I retriving a error "root cannot be resolved to a variable".
amatorIP
Junior Developer
Junior Developer
 
Posts: 10
Joined: Mon Jan 30, 2012 9:32 pm

Top

Re: return type of the variable

Postby Phyll » Sat Feb 04, 2012 6:34 pm

Hi amatorIP,

Make it like this:

Code: Select all
      public static Node getDoc(String wayToFile){
          /*Create a DOM Parser*/
          Node root = null;
          try {
                  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder builder = factory.newDocumentBuilder();
                  Document document = builder.parse(new FileInputStream(wayToFile));
                  root = document.getDocumentElement();
                                         
          /*handle exception creating DocumentBuilder*/
          } catch(ParserConfigurationException parserError){
                  Log.e(TAG, "Parser Configuration Error");
                  parserError.printStackTrace();
          }
          /*handle exception reading data from file*/
          catch (IOException fileException){
                  Log.e(TAG, "File IO Error");
                  fileException.printStackTrace();
          }
          /*handle exception parsing XML*/
          catch(SAXException parceException) {
                  Log.e(TAG, "Error Parsing Document");
                  parceException.printStackTrace();
          }
          return root;
      }


Note the root variable is no longer inside the try{} block.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 5 guests