I have a problem with Netbeans
file viewer. I have a string in Arabic that includes accents in top of each letter. When I remove the accents from the string, the letters display correctly. However, when I write the string with the accents, it gets somehow disordered (incorrect).
This is an example of what is happening:
- Text without accents (correct):
بسم الله الرحمن الرحيم
- Text with accents (incorrect):
it shows broken, but if i copy it here it prints correctly
- It should be like this (correct):
بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
The code I wrote is to read a text file that includes an arabic string along with its accents, then write it correctly in a new file, then at the end, it deletes the old file. This is the code:
public void arabicReformer(File disordered) {
File output = new File("data/temp2.txt");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(disordered), "UTF8"));
BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(output), "UTF8"));
String line;
while ((line = br.readLine()) != null) {
bw.write(line.trim() + "\n");
}
br.close();
bw.close();
} catch (UnsupportedEncodingException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
output.renameTo(disordered);
}
PS: when I copy past the incorrect arabic string with the accents here, it prints correctly!