Java Eclipse のコンソールに数行のコマンドを記述し、それらを .txt ファイルとして保存しようとしています。たとえば、私は持っています
これを行う
そんなことしたらダメ
私のコンソールで、.txt ファイルと同じものを持ちたいと思っています。これで、ファイルに変換できますが、.txt ファイルには変換できず、同じ読み取り可能な形状ではありません。助けはありますか?私は今3日間それに取り組んでいます:))
私はこれが私が得ることができる最も近いと思います
FileInputStream fileInputStream=null;
File file = new File("C:\\Users\\Administrator\\Desktop\\a.txt");
byte[] bFile = new byte[(int) file.length()];
try {
//convert file into array of bytes
fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
//convert array of bytes into file
FileOutputStream fileOuputStream =
new FileOutputStream("C:\\Users\\Administrator\\Desktop\\a.txt");
fileOuputStream.write(bFile);
fileOuputStream.close();
System.out.println("Done");
}catch(Exception e){
e.printStackTrace();
}