There isn't really an *easy* way to do it. You'll likely have to install the XPDF package, or something similar, and use it's text extractor to do it.
Assuming that the file contains just textual stuff, create an object to represent it: stuff = file ( 'stuff.txt' ) To read a line of the file at a time: line = stuff.readline() Python signals end-of-file by returning an empty line which you can test for in a construction such as the following: stuff = file ( 'stuff.txt' ) while True: line = stuff.readline() if line : # do something here pass else : break You can read the entire file using : whole_contents = stuff.read() If the file had contained binary then it would have been necessary to open it as such: stuff = file ( 'stuff.bn', 'b' )
You can use a variable to represent a the file that you are going to read. from there, you can display each line using the statement "line = file.gets)def samplefile = File.new("wildcat.txt")while (line = file.gets)puts "#{line}"endfile.closeend
To skip to a new line when reading from a file, assuming you are using a sequentially organized file, the usual case, you need to read and discard characters until you encounter the end-of-line character.
You need to use File class to create file in java and than Reader class implementation such as BufferedReder to read content.
I suggest something like this:* Open file1 and file2 * Create a temporary output file, for writing * Read a line from file1, write it into the output file * Read a line from file2, write it into the output file * Repeat the previous two steps, while you are not at end-of-file in either of the two files * At this point, if you are NOT at end-of-file in file1, read the remaining lines of file1, and write them to the output (you can write a loop for this). * Similarly, if you are NOT at end-of-file in file2, read and write the remaining file. * Close file1, file2, and the output file. * Copy the temporary output file back to file1 * Erase the temporary output file
If you mean to convert from one file type to another. You possibly can but it would take a lot of work. It would require a good understanding of both file types. You could read one line at a time from the input file using the FOR command and then modify the line in order to make it work as the other file type and then use the redirection operator > to send the output to a new file. And it may not be as simple as that because of the structure of each file type. I would recommend downloading an application to complete that task or use the information at the related links.
protect your file B by password. this will become a read only file
sure
you can use inputstream for reading the file java.io.fileinputstream and write the file using outputstream..
The class I find useful is the FileReader class in java.io. It allows you to read an external file in your program.For instance,Consider a file input.txt:HelloHow are you?1 2 3 4 5You can access it by:FileReader read = new FileReader("input.txt"); // pass the file name as a String//now the read is the file//can scan from the file using ScannerScanner scan = new Scanner(read);System.out.println( scan.nextLine()); // prints HelloSystem.out.println( scan.nextLine()); // prints How are you?while(scan.hasNextInt())System.out.print(scan.nextInt() + " "); // prints 1 2 3 4 5
read, fread, fgetc, fgets, fscanf etc... use the help/manual
I have the same problem............ I want to read and write file but using Xmodem..... Please help me out as soon as possible