我申请了这所大学,下周我要进行陈述。除了一个小细节外,一切都准备就绪:我使用条形码扫描器,但我只返回它扫描的数字。我很想将此号码更改为产品名称。寻找解决方案后,我没有找到。有人知道如何做到这一点吗?
最佳答案
我完全忘了发布它,但我确实找到了解决方案。我放了 2 个脚本,因为我不能从我的笔记本电脑上运行 android studio,所以我不能在这里发布我的最终代码。如果有人真的想看,我可以在不久的将来做到。但我的解决方案如下:我有一些网站,您可以在其中输入通过扫描代码和获取网站信息的 get 命令获得的数字,将其放入文件中并通过定位来使用有用的东西并将其拆分。
import java.io.IOException;
import javax.swing.JOptionPane;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class Main {
public static void main(final String[] args) throws IOException {
String inputValue = JOptionPane.showInputDialog("Please input barcode");
if (inputValue != null && inputValue.length() > 0) {
String url = "https://www.barcodable.com/ean/" + inputValue;
Document doc = Jsoup.connect(url).get();
JOptionPane.showMessageDialog(null, doc.title(), "result", JOptionPane.INFORMATION_MESSAGE);
}
}
关于android - 将条形码转换为产品名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48118284/