我正在尝试在 VS Code 中的 settings.json 文件中配置 JSON5 架构,[以具有智能感知]
我想做一些类似于今天可用于 JSON 编辑的事情https://code.visualstudio.com/docs/languages/json#_mapping-in-the-user-settings,如下所示
"json5.schemas": [
{
"fileMatch": [
"*test.json5"
],
"url": "https://example.com/json-schemas/example.json5"
}
]
Run Code Online (Sandbox Code Playgroud)
你能帮我实现这个目标吗(通过 VSCode 内的任何方式)?
动机:请注意,截至本文,IntelliJ IDEA 支持 JSON5 https://www.jetbrains.com/help/idea/json.html#ws_json_choose_version
以下代码尝试将换行符引入字节数组并将字节数组写入文件。
import java.io.*;
public class WriteBytes {
public static void main(String args[]) {
byte[] cities = { 'n', 'e', 'w', 'y', 'o', 'r', 'k', '\n', 'd', 'c' };
FileOutputStream outfile = null;
try {
outfile = new FileOutputStream("newfile.txt");
outfile.write(cities);
outfile.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
新文件的内容是:newyorkdc
我所期望的是:
纽约
特区
我尝试打字'\n'
但(byte)'\n'
无济于事。
解决方案:将数组初始化改为
byte[] cities = { 'n', 'e', 'w', 'y', 'o', 'r', 'k', '\r','\n', 'd', 'c' };
Run Code Online (Sandbox Code Playgroud)
我使用 Notepad++ 查看文件的内容。我想它抑制了换行符,但接受了回车符和换行符组合。
下面是map的一部分,其中map被初始化为:
Map<Integer,Integer> map = new HashMap<>();
和我想要修改输出的行是
System.out.println("Price and items "+map.toString());
目前的输出是
{100 = 10,200 = 5}
我要显示
{100:10,200:5}
Java如何实现以下字符串比较
public class MyClass {
public static void main(String args[]) {
String a = "Chaipau";
String b = "pau";
System.out.println(a == "Chai"+"pau"); //true
System.out.println(a == "Chai"+b); //false
}
}
Run Code Online (Sandbox Code Playgroud)
这与我如何比较Java中的字符串不同?,因为答案不包含在第二种情况下创建新对象的原因,因为它可能指向与第一种情况相同的对象引用.