text-files

Open a text file in the default text editor… via Java?

懵懂的女人 提交于 2019-11-26 13:07:31
问题 OK. Simple question. Maybe not so simple answer, though: I have a file I downloaded in Java, and I know that it\'s a text file. Is there any way that I can use Java to open that text file in whatever the default text editor is? It has to work for all OS\'s, otherwise I would just make it open with Notepad. :\\ I guess that if there\'s no way to do this I could use JOptionPane and show the contents of the text file... 回答1: You can do that with: java.awt.Desktop.getDesktop().edit(file); This

Simplest way to encrypt a text file in java

蹲街弑〆低调 提交于 2019-11-26 12:40:50
问题 For my School project I had to show that I can utilize file handling within a program. For this I made a very simple login process that you can create an account on that writes a username and password to a text file located in the resource folder. Obviously this has no security at all as it wasn\'t designed to be secure just to showcase file handling however my teacher has said that I should attempt to add some encryption to the file as well to get a better grade. I have done some research

How to monitor a text file in realtime [closed]

≯℡__Kan透↙ 提交于 2019-11-26 12:03:43
问题 For debugging purposes in a somewhat closed system, I have to output text to a file. Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time? 回答1: Tail for Win32 Apache Chainsaw - used this with log4net logs, may require file to be in a certain format 回答2: I like tools that will perform more than one task, Notepad++ is a great notepad replacement and has a Document Monitor plugin (installs with standard msi) that

Windows notepad not supporting newline character '\n'

白昼怎懂夜的黑 提交于 2019-11-26 11:30:23
问题 From my iPhone application I\'m outputting data from text to a file. When opened with windows notepad, the data is all on one line and where there should be a new line a block character is present (showing that it\'s an unrecognized character or something). When opened with windows wordpad, it displays just fine. Would there be something wrong in my code? I\'m simply output \'\\n\' when i want a new line. NOTE : It\'s working fine with other editors like textedit, MS Word on mac as well as on

Delete specific line from a text file?

早过忘川 提交于 2019-11-26 11:28:39
问题 I need to delete an exact line from a text file but I cannot for the life of me workout how to go about doing this. Any suggestions or examples would be greatly appreciated? Related Questions Efficient way to delete a line from a text file (C#) 回答1: If the line you want to delete is based on the content of the line: string line = null; string line_to_delete = "the line i want to delete"; using (StreamReader reader = new StreamReader("C:\\input")) { using (StreamWriter writer = new

How to overwrite only part of a file in c++

女生的网名这么多〃 提交于 2019-11-26 11:26:40
问题 I want to make modifications to the middle of a text file using c++, without altering the rest of the file. How can I do that? 回答1: If the replacement string is the same length, you can make the change in place. If the replacement string is shorter, you may be able to pad it with zero-width spaces or similar to make it the same number of bytes, and make the change in place. If the replacement string is longer, there just isn't enough room unless you first move all remaining data. 回答2: Use std

Java BufferedReader back to the top of a text file?

早过忘川 提交于 2019-11-26 11:22:13
问题 I currently have 2 BufferedReader s initialized on the same text file. When I\'m done reading the text file with the first BufferedReader , I use the second one to make another pass through the file from the top. Multiple passes through the same file are necessary. I know about reset() , but it needs to be preceded with calling mark() and mark() needs to know the size of the file, something I don\'t think I should have to bother with. Ideas? Packages? Libs? Code? Thanks TJ 回答1: What's the

Windows Batch: Set Variables from Text File

我的梦境 提交于 2019-11-26 11:19:38
问题 Im currently looking for a method to set variables in a windows batch file from linkes in txt document. So for example, if the text file reads: http://website1.com http://website2.com http://website3.com I can hopefully output them to variables in the batch. Example: set var1=\"Line one of text file, ex: http://website1.com\" set var2=\"Line two of text file, ex :http://website2.com\" set var3=\"Line three of text file, ex: http://website3.com\" Any help is appreciated, thanks in advance! 回答1

PHP to search within txt file and echo the whole line

这一生的挚爱 提交于 2019-11-26 11:18:13
Using php, I'm trying to create a script which will search within a text file and grab that entire line and echo it. I have a text file (.txt) titled "numorder.txt" and within that text file, there are several lines of data, with new lines coming in every 5 minutes (using cron job). The data looks similar to: 2 aullah1 7 name 12 username How would I go about creating a php script which will search for the data "aullah1" and then grab the entire line and echo it? (Once echoed, it should display "2 aullah1" (without quotations). If I didn't explain anything clearly and/or you'd like me to

Historical reason behind different line ending at different platforms

喜夏-厌秋 提交于 2019-11-26 11:16:21
问题 Why did DOS/Windows and Mac decide to use \\r\\n and \\r for line ending instead of \\n? Was it just a result of trying to be \"different\" from Unix? And now that Mac OS X is Unix (-like), did Apple switch to \\n from \\r? 回答1: DOS inherited CR-LF line endings (what you're calling \r\n, just making the ascii characters explicit) from CP/M. CP/M inherited it from the various DEC operating systems which influenced CP/M designer Gary Kildall. CR-LF was used so that the teletype machines would