如何将png文件作为参数传递给java中的方法?
问题描述:
import java.io.File;
import net.sourceforge.tess4j.*;
public class TesseractExample{
public static void main(String[] args) {
File imageFile = new File("C:\\test\\a.tif");
Tesseract instance = Tesseract.getInstance(); // JNA Interface Mapping
// Tesseract1 instance = new Tesseract1(); // JNA Direct Mapping
try {
String result = instance.doOCR(imageFile);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
}
}
以上程序是硬编码的,因为我正在路过使用path的tif文件。我想要的是将图像文件从其他程序直接传递给这个方法。请告诉我如何实现它?
The above program is hard coded because I''m passing the tif file using the path.What I want is to pass the image files directly to this method from other program.Please suggest How I can achieve it?
答
这个方式: http://docs.oracle.com/javase/tutorial/java/javaOO/methods。 html [ ^ ]
请阅读教程,我可以建议购买一本关于java开发的书。
this way: http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html[^]
PLease read the tutorials and I can recommend to buy a book on java development.