text-files

How to add new line into txt file

此生再无相见时 提交于 2019-11-26 17:27:33
问题 I'd like to add new line with text to my date.txt file, but instead of adding it into existing date.txt, app is creating new date.txt file.. TextWriter tw = new StreamWriter("date.txt"); // write a line of text to the file tw.WriteLine(DateTime.Now); // close the stream tw.Close(); I'd like to open txt file, add some text, close it, and later after clicking something: open date.txt, add text, and close it again. So i can get: Button pressed: txt opened -> added current time, then close it.

objective C: write in a csv (txt) string contained in some textfield

巧了我就是萌 提交于 2019-11-26 17:25:56
问题 In my project I have a view where I write words in some textfield, when I press a button these string must be stored in a csv file as this example: (example with 5 textfield) firststring#secondstring#thirdstring#fourthstring#fifthstring; this is an example of the result that I want. How can I do? Edited to add: code for the string NSMutableString *csvString = [NSMutableString stringWithString:textfield1.text]; [csvString appendString:@"#"]; [csvString appendString:textfield2.text]; [csvString

Getting all file names from a folder using C# [duplicate]

吃可爱长大的小学妹 提交于 2019-11-26 17:18:41
This question already has an answer here: How to recursively list all the files in a directory in C#? 19 answers I wanted to know if it is possible to get all the names of text files in a certain folder. For example, I have a folder with the name Maps, and I would like to get the names of all the text files in that folder and add it to a list of strings. Is it possible, and if so, how I can achieve this? Gopesh Sharma DirectoryInfo d = new DirectoryInfo(@"D:\Test");//Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.txt"); //Getting Text files string str = ""; foreach(FileInfo file

Preserving leading white space while reading>>writing a file line by line in bash

依然范特西╮ 提交于 2019-11-26 17:08:34
问题 I am trying to loop through a directory of text files and combine them into one document. This works great, but the text files contain code snippets, and all of my formatting is getting collapsed to the left. All leading whitespace on a line is stripped. #!/bin/sh OUTPUT="../best_practices.textile" FILES="../best-practices/*.textile" for f in "$FILES" do echo "Processing $f file..." echo "">$OUTPUT cat $f | while read line; do echo "$line">>$OUTPUT done echo >>$OUTPUT echo >>$OUTPUT done I am

Remove unicode characters from textfiles - sed , other bash/shell methods

点点圈 提交于 2019-11-26 16:16:06
How do I remove unicode characters from a bunch of text files on the terminal? I've tried this but it didn't work: sed 'g/\u'U+200E'//' -i *.txt I need to remove these unicodes from the textfiles U+0091 - sort of weird "control" space U+0092 - same sort of weird "control" space A0 - non-space break U+200E - left to right mark If you want to remove ONLY particular characters and you have python, you can: CHARS=$(python -c 'print u"\u0091\u0092\u00a0\u200E".encode("utf8")') sed 's/['"$CHARS"']//g' < /tmp/utf8_input.txt > /tmp/ascii_output.txt clear all non-ascii chars of file.txt $ iconv -c -f

Line break not working when writing to text file in PHP

孤者浪人 提交于 2019-11-26 16:13:25
问题 I have the following test script: <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "Floppy Jalopy\n"; fwrite($fh, $stringData); $stringData = "Pointy Pinto\n"; fwrite($fh, $stringData); fclose($fh); ?> when run however and opened usign Notepad, the data is returned in a single line without breaks as: Floppy Jalopy(crazy box)Pointy Pinto(crazy box) where i cant find the appropriate character for 'crazy box' but its a REALLY crazy box. WHAT

Append text or data to text file in Swift

混江龙づ霸主 提交于 2019-11-26 15:24:53
I already have read Read and write data from text file I need to append the data (a string) to the end of my text file. One obvious way to do it is to read the file from disk and append the string to the end of it and write it back, but it is not efficient, especially if you are dealing with large files and doing in often. So the question is "How to append string to the end of a text file, without reading the file and writing the whole thing back"? so far I have: let dir:NSURL = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.CachesDirectory, inDomains:

Find lines from a file which are not present in another file [duplicate]

允我心安 提交于 2019-11-26 15:13:16
问题 This question already has answers here : Fast way of finding lines in one file that are not in another? (11 answers) Closed 2 years ago . I have two files (let's say a.txt and b.txt ), both of which has a list of names. I have already run sort on both the files. Now I want to find lines from a.txt which are not present in b.txt . (I spent lot of time to find the answer for this question, so documenting it for future reference) 回答1: The command you have to use is not diff but comm comm -23 a

Tools to search for strings inside files without indexing [closed]

。_饼干妹妹 提交于 2019-11-26 15:00:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I have to change some connection strings in an incredibly old legacy application, and the programmers who made it thought it would be a great idea to plaster the entire app with connection strings all over the place. Visual Studio's "current project" search is incredible slow, and I don't trust Windows Search.

How do I populate JComboBox from a text file?

女生的网名这么多〃 提交于 2019-11-26 14:49:06
问题 How do I populate a JComboBox from a text file? 回答1: Very vague question. Are you saying you want one entry per line? If so you want to use something like a BufferedReader, read all the lines, save them as a String array. Create a new JComboBox passing in that String constructor. BufferedReader input = new BufferedReader(new FileReader(filePath)); List<String> strings = new ArrayList<String>(); try { String line = null; while (( line = input.readLine()) != null){ strings.add(line); } } catch