小编Max*_*its的帖子

Intellij IDEA checkstyle

我在尝试将我的支票样式导入IDEA 14时遇到了问题.这就是我所做的:

  1. 文件 - >设置 - >检查 - >导入
  2. 在那里我选择了我的checkstyle.xml,然后我不知道为什么会创建TempProfile.
  3. 嗯,好吧,看起来这个TempProfile可以使用我的checkstyle.xml检查我的代码,但事实并非如此!

java intellij-idea checkstyle

23
推荐指数
2
解决办法
5万
查看次数

Java replaceAll("\\ s +")vs replaceAll("\\\\ s +")

replaceAll("\\s+")和之间有什么区别replaceAll("\\\\s+")?通常我会使用\\s+但有时我会看到\\\\s+.

java replaceall

5
推荐指数
1
解决办法
3万
查看次数

System.console()在NetBeans中提供NullPointerException

我是Java的新手.

我有以下问题:方法readLine()或者nextLine(),nextInt()等抛出异常:NullPointerException.

我使用NetBeans IDE(如果重要的话).

public static void Reading()
{

    String qq;
    qq = System.console().readLine();
    System.console().printf(qq);
}
Run Code Online (Sandbox Code Playgroud)

java console netbeans exception nullpointerexception

4
推荐指数
1
解决办法
7193
查看次数

从文件Java中读取字节

我正在尝试解析我的文件,它将所有数据保存为二进制形式.如何从偏移量为M的文件中读取N个字节?然后我需要使用它将其转换为String new String(myByteArray, "UTF-8");.谢谢!

这是一些代码:

File file = new File("my_file.txt");
byte [] myByteArray = new byte [file.lenght];
Run Code Online (Sandbox Code Playgroud)

UPD 1:我看到的答案并不合适.我的文件以字节形式保存字符串,例如:当我在我的文件中放入字符串"str"时,它实际上打印出类似[B @ 6e0b ...在我的文件中的smth.因此,我需要再次从这个字节码中获取我的字符串"str".

UPD 2:当我发现问题出现时,我使用toString():

    PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(System.getProperty("db.file")), true), "UTF-8")));
    Iterator it = storage.entrySet().iterator();//storage is a map<String, String>
    while (it.hasNext()){
        Map.Entry pairs = (Map.Entry)it.next();
        String K = new String(pairs.getKey().toString());
        String V = new String(pairs.getValue().toString);
        writer.println(K.length() + " " + K.getBytes() + " " + V.length() + " " + V.getBytes());//this is just the format …
Run Code Online (Sandbox Code Playgroud)

java file

-1
推荐指数
1
解决办法
1888
查看次数