
02-07-2006, 15:17
|
|
|
|
חבר מתאריך: 14.07.05
הודעות: 558
|
|
|
[JAVA] בעית בכיתבת קבצים
שלום,
אני כותב קבצים (יוצר) על ידי תוכנה שבניתי ..
קוד:
String getext;
getext = getTitle();
Component aComponent = null;
int returnVal = jfc.showSaveDialog(aComponent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = jfc.getSelectedFile();
try {
title = jfc.getSelectedFile().getName();
FileWriter fi = new FileWriter(file);
PrintWriter os = new PrintWriter(fi);
os.write(textarea.getText());
setTitle(title +" - Chibi Editor");
os.close(); fi.close();
}
catch(IOException e) {
JOptionPane.showMessageDialog(null,"Error While Open File:."+ title +"\n"+ e,"Error!",JOptionPane.ERROR_MESSAGE);
}
}
עכשיו זה עובד אבל הבעיה היא שכאשר אני רוצה לפתוח את הקובץ שאני שומר (TXT) בעזרת נגיד NOTEPAD אין אנטרים והכל מודפס בשורה אחת...
(אם אני פותח את זה דרך הקוד שלי אז אין בעיה:
קוד:
Object openButton;
Component aComponent = null;
int returnVal = jfc.showOpenDialog(aComponent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = jfc.getSelectedFile();
try {
FileReader fr = new FileReader(file);
BufferedReader is = new BufferedReader(fr);
String s1 = is.readLine();
text = "";
title = jfc.getSelectedFile().getName();
setTitle(title +" - Chibi Editor");
for(int i=1;s1!=null;i=i+1) {
text = text + s1 + "\n";
s1 = is.readLine();
textarea.setText(text);
}
is.close();
}
catch(IOException e) {
JOptionPane.showMessageDialog(null,"Error While Open File:."+ title +"\n"+ e,"Inane error",JOptionPane.ERROR_MESSAGE);
}
}
בתודה מראש אלעד..
למי שלא הבין אני רוצה להדפיס עם אנטרים (N\ רווח שורה )שגם בנגיד NOTEPAD יראו את הירידות שורה
_____________________________________
Your signature did not follow Fresh's signatures policy, therefore it was automatically erased. Please see the E-Mail which has been sent to you, to learn how to fix this.
|