It all depends on the library where you get your code from:
Here below is from Maven:
http://grepcode.com/file/repo1.maven.org/maven2/com.lowagie/itext/2.0.1/com/lowagie/text/pdf/BarcodeEAN.java
Similar to your code above, it has "setCode()" API (see the left frame windows and click on it) to allow you to input the numbers to be converted to images.
And it also has "getCode()" which allow you to do vice versa.
Look up your library API for details.