I am doing a little home project to learn more about collections and FileIO. I have made a little racing app where the user enters the racers details all of which are strings, and these details are inserted into a List<T> list and then once the user clicks the 'save' button the contents of the list are extracted to a text file. I have successfully been able to write to the text file however I now want to change this so I am able to append the data to the text file instead of the previous data being overwritten each …

Member Avatar
Member Avatar
+0 forum 3

I have been learning about the collections namespace in C# so have been doing some little self-made projects to learn. I have made a car race app where you enter in the name, car and place of the racer this is then stored in an array list. I can extract the contents of my array list onto the console window but I would like to know how I can write and save it to a text file (kindof like a mini database). I know that every element stored in an array list is stored as an object therefore casting is …

Member Avatar
Member Avatar
+0 forum 5

I have a bit of a baffling problem! I'm writing a tag matcher in XML and whenever I run the below procedure, I get a garbage value after the name of every tag **except for the first one**. When I add the array text to the parameters list, the garbage value goes away (I had it there during initial debugging) even though it isn't actually referenced at any point in the procedure. Another thing, is that while reading a tag, it doesn't seem to want to recognize spaces. For example, <img src="img.png"/> reads as imgsrc="imgpng" instead of img, but only …

Member Avatar
Member Avatar
+0 forum 1

I am trying to write a program that creates a new file every time I use the application. Right now, this is what I am doing: outfile.open("Application.txt"); outfile<<"First Name: "<< firstName <<" "<<"Last Name: "<< lastName<<" "<<"Student Number: "<< studentNumber << endl; outfile<<"Email Address: " << emailAddress <<" "<< "Major: " << major << " " <<"Year standing: "<< yearStanding << endl; outfile<<"CGPA: "<< culmativeGPA <<" "<<"MajorGPA: "<< majorGPA << endl; outfile.close(); What I want to actually do, is check if application001.txt exists, and if it doesn't, create that file then write to it, and then close it. If it …

Member Avatar
Member Avatar
+0 forum 3

I'm noob at GUI Swing. I have 2 questions. 1)I'm trying to implement a program that reads a text file, so I can use it to add multiple tabs to the program based on the amount of data in the text file. For example, text file have 3 names. I will use the 3 names to make 3 tabs labeling their name in each of them. Where do I call this fileIO, readContacts() part? When I put readContacts() in the Constructor AddTabs(), the program cannot display the frame. When I take readContacts() out of the Contructor, the the program can …

Member Avatar
Member Avatar
+0 forum 12

Hi All, If I read in from a file and populate an array with its data(all strings), how can I control the way it prints(to the console for example).Right now it just prints a huge long line in the console of all its contents. I figure I will have to implement for loops to get it to print line by line from the text file. My main goal is eventual learning how to print it to an excel file but I am taking baby steps there to learn how to manipulate an array. Also, would an arrayList be a better …

Member Avatar
Member Avatar
+0 forum 13

According to the Python 2.7 manual this construction of the with statement should work: [code]text = "aim low and reach it" fname = "test7.txt" with open(fname, 'w') as foutp, open(fname, 'r') as finp: # write text to file foutp.write(text) # read text from file mytext = finp.read() print("to file --> %s" % text) print('-'*30) print("from file --> %s" % mytext) """ my result --> to file --> aim low and reach it ------------------------------ from file --> """ [/code]It writes the file out, but does not read it in. There is no error traceback.

Member Avatar
Member Avatar
+1 forum 4

The End.