How do I convert the FileWriter
to OutputStreamWriter
? This is the directory that I stored the .java files. src/RX/example.java
where RX is the package name. I inserted all the images and text files inside the same directory. Here is my working code with FileWriter.
try {
StringReader stringReader = new StringReader("Save this Message");
BufferedReader bufferedReader = new BufferedReader(stringReader);
FileWriter fileWriter = new FileWriter("src/RX/rxUser.txt");
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
for(String line = bufferedReader.readLine(); line != null; line =bufferedReader.readLine()) {
bufferedWriter.write(line);
bufferedWriter.newLine();
}
bufferedReader.close();
bufferedWriter.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I actually can go on with this code but in order to work with .jar I have to use the .txt file as a resource. Can someone please alter my code. I am using Netbeans. Thank you.