File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes OOP Passing parameter back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OOP Passing parameter back" Watch "OOP Passing parameter back" New topic
Author

OOP Passing parameter back

Roberto Gonsales
Greenhorn

Joined: Sep 26, 2011
Posts: 5
Hello everybody, I need some help. I'm writing program which takes bunch of text files with different charset encoding and converts these files to another one charset. My program is almost done, but one key thing. How do I pass 'charset' parameter of Notify method in CharsetDetector class back to Converter class?



Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

I'm not clear on when or why your notify() method is called, but I think the most logical way to get the results of detectCharset() into your converter would be to return it from detectCharset().

A couple of extra suggestions:

1. Wrap your reader and writer in BufferedReader and BufferedWriter and you'll see a dramatic increase in performance.
2. Learn the capitalization conventions for Java. Classes and Interfaces should start with a capital. Methods and variables start with lowercase. Following conventions like these make your code much more readable.
Roberto Gonsales
Greenhorn

Joined: Sep 26, 2011
Posts: 5
Greg, thank you for reply. I changed code in accordance with your recommendations to use BufferedReader and BufferedWriter.
Interface nsICharsetDetectionObserver is part of jChardet library. nsDetector fires the Notify() method between nsDetector.DoIt() and nsDetector.DataEnd() calls. I changed CharsetDetector class to get result only in Notify() method. So how do I get the result back to Converter class?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OOP Passing parameter back
 
Similar Threads
Getting Different File Sizes from the server.
HTTP method GET is not supported by this URL
error while reading objects from file
java.util.Logger creating multiple log files
Log events to a file