终端粘贴url会打开浏览器(Pasting url to Terminal will open browser)

Answered

我的英语比较糟糕,所以先用中文描述,再将机器翻译的结果贴在下面,如果有人能帮忙翻译十分感谢。运行一个需要从控制台输入的程序(使用BufferReader方式)当我粘贴一个url地址进去,按下回车键会打开浏览器。而当我手动打url却不会发生这种情况。

下面是我的代码,是一个接收字符串并生成二维码的程序:

public class Main {
public static void main(String[] args) throws WriterException, IOException {
InputStreamReader inputStreamReader = new InputStreamReader(System.in);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

String data = bufferedReader.readLine();

//qr style
int height = 300;
int width = 300;
String format = "png";

Map<EncodeHintType, String> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");

BitMatrix bitMatrix = new MultiFormatWriter().encode(data, BarcodeFormat.QR_CODE, width, height, hints);
Desktop desktop = Desktop.getDesktop();
File file = new File("./" + File.separator + "hello.png");
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
desktop.open(file);
}
}
//这个会打开浏览器,如果我是手动输入的则不会

----------------------------

I"m not good at English,so i described this problemwith Chinese.When i paste a url such as 'http://127.0.0.1', then press enter, the idea will open this url with browser instead of handling String.But the manual typing url is correct.My code:

public class Main {
public static void main(String[] args) throws WriterException, IOException {
InputStreamReader inputStreamReader = new InputStreamReader(System.in);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

String data = bufferedReader.readLine();

//qr style
int height = 300;
int width = 300;
String format = "png";

Map<EncodeHintType, String> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");

BitMatrix bitMatrix = new MultiFormatWriter().encode(data, BarcodeFormat.QR_CODE, width, height, hints);
Desktop desktop = Desktop.getDesktop();
File file = new File("./" + File.separator + "hello.png");
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
desktop.open(file);
}
}

 

 

0
1 comment

Thanks for the report, I've reproduced the problem and submitted a bug here: https://youtrack.jetbrains.com/issue/IDEA-178391. Please follow it for updates. See https://intellij-support.jetbrains.com/hc/articles/207241135 if you are not familiar with YouTrack.

1

Please sign in to leave a comment.