如何将png文件作为参数传递给java中的方法? [英] How to pass a png file as a parameter to a method in java?
本文介绍了如何将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.
这篇关于如何将png文件作为参数传递给java中的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文