Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 提取文件中的值并将其转换为字符串以实现更多功能_Java_Encryption_Netbeans - Fatal编程技术网

Java 提取文件中的值并将其转换为字符串以实现更多功能

Java 提取文件中的值并将其转换为字符串以实现更多功能,java,encryption,netbeans,Java,Encryption,Netbeans,因此,我需要读取一个文本文件并将其转换为字符串,以便开始使用shift-chipper对我的msg进行削片。 我所发现的所有如何读取文本文件都涉及到一个循环,它本身只显示从第一个到下一个的打印字符,直到没有更多的文本为止 File fl = new File("d:/chipper/msg/msg.txt"); BufferedReader brText = new BufferedReader(new FileReader(fl)); String text = null; while((te

因此,我需要读取一个文本文件并将其转换为字符串,以便开始使用shift-chipper对我的msg进行削片。 我所发现的所有如何读取文本文件都涉及到一个循环,它本身只显示从第一个到下一个的打印字符,直到没有更多的文本为止

File fl = new File("d:/chipper/msg/msg.txt");
BufferedReader brText = new BufferedReader(new FileReader(fl));
String text = null;
while((text=brText.readLine())!=null){
System.out.println(text);
}
brPesan.close(); 
有没有办法让我

File fl = new File("d:/chipper/msg/msg.txt");
textToChipper = fl;
chipper();

你可以这样做:

textToChipper = new String(Files.readAllBytes(Paths.get("d:/chipper/msg/msg.txt")));
可能有助于复制