GUI Application for writing notesWriting a list to a file with PythonWriting files in Node.jsHow to write to file in Ruby?How do I create a file and write to it in Java?How to write content on a text file using java?Correct way to write line to file?Java Inventory Program problemsClone a Singleton objectwhy spill failure happens for Custom Data Type in HadoopJava - Method executed prior to Default Constructor

Is the claim "Employers won't employ people with no 'social media presence'" realistic?

Do I have an "anti-research" personality?

What happened to Captain America in Endgame?

Is it idiomatic to construct against `this`

'It addicted me, with one taste.' Can 'addict' be used transitively?

How can I get this effect? Please see the attached image

"Hidden" theta-term in Hamiltonian formulation of Yang-Mills theory

Can someone publish a story that happened to you?

How would 10 generations of living underground change the human body?

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

How to limit Drive Letters Windows assigns to new removable USB drives

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

Elements that can bond to themselves?

Critique of timeline aesthetic

How to have a sharp product image?

How did Captain America manage to do this?

Was there a shared-world project before "Thieves World"?

Why does Mind Blank stop the Feeblemind spell?

Can we say “you can pay when the order gets ready”?

What are the steps to solving this definite integral?

Coordinate my way to the name of the (video) game

Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?

Why does nature favour the Laplacian?

Does tea made with boiling water cool faster than tea made with boiled (but still hot) water?



GUI Application for writing notes


Writing a list to a file with PythonWriting files in Node.jsHow to write to file in Ruby?How do I create a file and write to it in Java?How to write content on a text file using java?Correct way to write line to file?Java Inventory Program problemsClone a Singleton objectwhy spill failure happens for Custom Data Type in HadoopJava - Method executed prior to Default Constructor






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-4















I am developing a GUI application that lets you add pieces of text to a note.txt.
The problem that I have is when I try to add a text it only adds a "0" and if you try to run the project it crashes. In the past it did not even recognise that the file even exist (somehow I got that fixed).



Figured out that the problem is here private void readAllNotes() class.



Would be grateful is someone could help.



here is my repository of the project on github, feel free to give advice on any part of the code.
https://github.com/justcain/GUI-Easy-snippets



public class AllNotes extends CommonCode 


ArrayList<Note> allNotes = new ArrayList<>();
private String crse = "";
private int maxID = 0;

AllNotes()
readAllNotes();


public final int getMaxID()
maxID++;
return maxID;


private void readAllNotes()
ArrayList<String> readNotes = new ArrayList<>();

readNotes = readTextFile(appDir + fileSeparator + "\Notes.txt");
//System.out.println(readNotes.get(0));

if (!"File not found".equals(readNotes.get(0)))
allNotes.clear();
for (String str : readNotes)
String[] tmp = str.split("t");
System.out.println(str);

Note n = new Note();
n.setNoteID(Integer.parseInt(tmp[0]));
n.setCourse(tmp[1]);
n.setDayte(tmp[2]);
n.setNote(tmp[3]);

allNotes.add(n);

/*int nid = Integer.parseInt(tmp[0]);
Note n = new Note(nid, tmp[1], tmp[2], tmp[3]);
allNotes.add(n);

if (nid > maxID)
maxID = nid;
*/



maxID++;


public void addNote(int maxID, String course, String note)
Note myNote = new Note(maxID, course, note);
allNotes.add(myNote);
writeAllNotes();


public ArrayList<Note> getAllNotes()
return allNotes;


private void writeAllNotes()
String path = appDir + fileSeparator + "\Notes.txt";
ArrayList<String> writeNote = new ArrayList<>();

allNotes.stream().map((n) ->
String tmp = n.getNoteID() + "t";
tmp += n.getCourse() + "t";
tmp += n.getDayte() + "t";
tmp += n.getNote();
return tmp;
).forEachOrdered((tmp) ->
writeNote.add(tmp);
);
try
//FileWriter writer = new FileWriter("path");
//BufferedWriter bw = new BufferedWriter(writer);
writeTextFile(path, writeNote);
catch (IOException e)
System.out.println("Problem! " + path);



public String searchAllNotesByKeyword(String noteList, int i, String s)
if (i == allNotes.size())
return noteList;


if (allNotes.get(i).getNote().contains(s))
noteList += allNotes.get(i).getNote() + "n";


return searchAllNotesByKeyword(noteList, i + 1, s);












share|improve this question
























  • Never mind. Fixed the code

    – justcain
    Mar 22 at 17:49











  • "Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

    – Andrew Thompson
    Mar 23 at 2:07


















-4















I am developing a GUI application that lets you add pieces of text to a note.txt.
The problem that I have is when I try to add a text it only adds a "0" and if you try to run the project it crashes. In the past it did not even recognise that the file even exist (somehow I got that fixed).



Figured out that the problem is here private void readAllNotes() class.



Would be grateful is someone could help.



here is my repository of the project on github, feel free to give advice on any part of the code.
https://github.com/justcain/GUI-Easy-snippets



public class AllNotes extends CommonCode 


ArrayList<Note> allNotes = new ArrayList<>();
private String crse = "";
private int maxID = 0;

AllNotes()
readAllNotes();


public final int getMaxID()
maxID++;
return maxID;


private void readAllNotes()
ArrayList<String> readNotes = new ArrayList<>();

readNotes = readTextFile(appDir + fileSeparator + "\Notes.txt");
//System.out.println(readNotes.get(0));

if (!"File not found".equals(readNotes.get(0)))
allNotes.clear();
for (String str : readNotes)
String[] tmp = str.split("t");
System.out.println(str);

Note n = new Note();
n.setNoteID(Integer.parseInt(tmp[0]));
n.setCourse(tmp[1]);
n.setDayte(tmp[2]);
n.setNote(tmp[3]);

allNotes.add(n);

/*int nid = Integer.parseInt(tmp[0]);
Note n = new Note(nid, tmp[1], tmp[2], tmp[3]);
allNotes.add(n);

if (nid > maxID)
maxID = nid;
*/



maxID++;


public void addNote(int maxID, String course, String note)
Note myNote = new Note(maxID, course, note);
allNotes.add(myNote);
writeAllNotes();


public ArrayList<Note> getAllNotes()
return allNotes;


private void writeAllNotes()
String path = appDir + fileSeparator + "\Notes.txt";
ArrayList<String> writeNote = new ArrayList<>();

allNotes.stream().map((n) ->
String tmp = n.getNoteID() + "t";
tmp += n.getCourse() + "t";
tmp += n.getDayte() + "t";
tmp += n.getNote();
return tmp;
).forEachOrdered((tmp) ->
writeNote.add(tmp);
);
try
//FileWriter writer = new FileWriter("path");
//BufferedWriter bw = new BufferedWriter(writer);
writeTextFile(path, writeNote);
catch (IOException e)
System.out.println("Problem! " + path);



public String searchAllNotesByKeyword(String noteList, int i, String s)
if (i == allNotes.size())
return noteList;


if (allNotes.get(i).getNote().contains(s))
noteList += allNotes.get(i).getNote() + "n";


return searchAllNotesByKeyword(noteList, i + 1, s);












share|improve this question
























  • Never mind. Fixed the code

    – justcain
    Mar 22 at 17:49











  • "Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

    – Andrew Thompson
    Mar 23 at 2:07














-4












-4








-4








I am developing a GUI application that lets you add pieces of text to a note.txt.
The problem that I have is when I try to add a text it only adds a "0" and if you try to run the project it crashes. In the past it did not even recognise that the file even exist (somehow I got that fixed).



Figured out that the problem is here private void readAllNotes() class.



Would be grateful is someone could help.



here is my repository of the project on github, feel free to give advice on any part of the code.
https://github.com/justcain/GUI-Easy-snippets



public class AllNotes extends CommonCode 


ArrayList<Note> allNotes = new ArrayList<>();
private String crse = "";
private int maxID = 0;

AllNotes()
readAllNotes();


public final int getMaxID()
maxID++;
return maxID;


private void readAllNotes()
ArrayList<String> readNotes = new ArrayList<>();

readNotes = readTextFile(appDir + fileSeparator + "\Notes.txt");
//System.out.println(readNotes.get(0));

if (!"File not found".equals(readNotes.get(0)))
allNotes.clear();
for (String str : readNotes)
String[] tmp = str.split("t");
System.out.println(str);

Note n = new Note();
n.setNoteID(Integer.parseInt(tmp[0]));
n.setCourse(tmp[1]);
n.setDayte(tmp[2]);
n.setNote(tmp[3]);

allNotes.add(n);

/*int nid = Integer.parseInt(tmp[0]);
Note n = new Note(nid, tmp[1], tmp[2], tmp[3]);
allNotes.add(n);

if (nid > maxID)
maxID = nid;
*/



maxID++;


public void addNote(int maxID, String course, String note)
Note myNote = new Note(maxID, course, note);
allNotes.add(myNote);
writeAllNotes();


public ArrayList<Note> getAllNotes()
return allNotes;


private void writeAllNotes()
String path = appDir + fileSeparator + "\Notes.txt";
ArrayList<String> writeNote = new ArrayList<>();

allNotes.stream().map((n) ->
String tmp = n.getNoteID() + "t";
tmp += n.getCourse() + "t";
tmp += n.getDayte() + "t";
tmp += n.getNote();
return tmp;
).forEachOrdered((tmp) ->
writeNote.add(tmp);
);
try
//FileWriter writer = new FileWriter("path");
//BufferedWriter bw = new BufferedWriter(writer);
writeTextFile(path, writeNote);
catch (IOException e)
System.out.println("Problem! " + path);



public String searchAllNotesByKeyword(String noteList, int i, String s)
if (i == allNotes.size())
return noteList;


if (allNotes.get(i).getNote().contains(s))
noteList += allNotes.get(i).getNote() + "n";


return searchAllNotesByKeyword(noteList, i + 1, s);












share|improve this question
















I am developing a GUI application that lets you add pieces of text to a note.txt.
The problem that I have is when I try to add a text it only adds a "0" and if you try to run the project it crashes. In the past it did not even recognise that the file even exist (somehow I got that fixed).



Figured out that the problem is here private void readAllNotes() class.



Would be grateful is someone could help.



here is my repository of the project on github, feel free to give advice on any part of the code.
https://github.com/justcain/GUI-Easy-snippets



public class AllNotes extends CommonCode 


ArrayList<Note> allNotes = new ArrayList<>();
private String crse = "";
private int maxID = 0;

AllNotes()
readAllNotes();


public final int getMaxID()
maxID++;
return maxID;


private void readAllNotes()
ArrayList<String> readNotes = new ArrayList<>();

readNotes = readTextFile(appDir + fileSeparator + "\Notes.txt");
//System.out.println(readNotes.get(0));

if (!"File not found".equals(readNotes.get(0)))
allNotes.clear();
for (String str : readNotes)
String[] tmp = str.split("t");
System.out.println(str);

Note n = new Note();
n.setNoteID(Integer.parseInt(tmp[0]));
n.setCourse(tmp[1]);
n.setDayte(tmp[2]);
n.setNote(tmp[3]);

allNotes.add(n);

/*int nid = Integer.parseInt(tmp[0]);
Note n = new Note(nid, tmp[1], tmp[2], tmp[3]);
allNotes.add(n);

if (nid > maxID)
maxID = nid;
*/



maxID++;


public void addNote(int maxID, String course, String note)
Note myNote = new Note(maxID, course, note);
allNotes.add(myNote);
writeAllNotes();


public ArrayList<Note> getAllNotes()
return allNotes;


private void writeAllNotes()
String path = appDir + fileSeparator + "\Notes.txt";
ArrayList<String> writeNote = new ArrayList<>();

allNotes.stream().map((n) ->
String tmp = n.getNoteID() + "t";
tmp += n.getCourse() + "t";
tmp += n.getDayte() + "t";
tmp += n.getNote();
return tmp;
).forEachOrdered((tmp) ->
writeNote.add(tmp);
);
try
//FileWriter writer = new FileWriter("path");
//BufferedWriter bw = new BufferedWriter(writer);
writeTextFile(path, writeNote);
catch (IOException e)
System.out.println("Problem! " + path);



public String searchAllNotesByKeyword(String noteList, int i, String s)
if (i == allNotes.size())
return noteList;


if (allNotes.get(i).getNote().contains(s))
noteList += allNotes.get(i).getNote() + "n";


return searchAllNotesByKeyword(noteList, i + 1, s);









java file file-io text-files






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 2:07









Andrew Thompson

154k29166352




154k29166352










asked Mar 22 at 17:30









justcainjustcain

1




1












  • Never mind. Fixed the code

    – justcain
    Mar 22 at 17:49











  • "Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

    – Andrew Thompson
    Mar 23 at 2:07


















  • Never mind. Fixed the code

    – justcain
    Mar 22 at 17:49











  • "Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

    – Andrew Thompson
    Mar 23 at 2:07

















Never mind. Fixed the code

– justcain
Mar 22 at 17:49





Never mind. Fixed the code

– justcain
Mar 22 at 17:49













"Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

– Andrew Thompson
Mar 23 at 2:07






"Never mind. Fixed the code" Please either enter the solution below, or delete the question. As it stands, this Q(&A) brings no value to future visitors. BTW - you mention a GUI. If Swing, look at JTextComponent.write(Writer).

– Andrew Thompson
Mar 23 at 2:07













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304955%2fgui-application-for-writing-notes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304955%2fgui-application-for-writing-notes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴