how to read and write files in java?
107183
I think this is best answered by an example (I don't know how to keep formatting in Yahoo! Answers, so the formatting of the code is lost)\n\nfile TestFile.java\n===================\n\nimport java.io.*;\n\npublic class TestFile {\n\n   public static void main(String[] args) {\n      String inFilename = args[0];\n      String outFilename = args[1];\n      try {\n         BufferedReader in = \n            new BufferedReader(new FileReader(inFilename));\n         FileWriter out = new FileWriter(outFilename);\n         \n         String line = in.readLine();\n         while(line != null) {\n            out.write(line + "&#92;n");\n            line = in.readLine();\n         }\n         \n         out.close();\n         in.close();\n      } \n      catch(IOException ioe) {\n         ioe.printStackTrace();\n      }\n   }\n}\n\nThis simply takes two String arguments.  The first is used as a source file, the second is used as a destination file.  Everthing in the source file is copied into the destination file.  Anything that existed in the destination file is overwritten.\n\nThe Buffered reader makes it really easy to read from text files.  As you can see opening a file is as easy as creating a new instance of a FileReader or FileWriter.  Take a look at the Javadocs for these classes for more information.\n\nSince Java is a cross-platform language, you should add extra code for handling a file regardless of the operating system, but this should get you started.
122585
Click the file to select it.\nHold down CTRL key\nRight click on the file\nChoose Open With from the menu by clicking it.\nBrowse to appropriate program or application to open it.
30653
You can execute the system call of dir and pipe output to a file/string/strings and then do a search or pattern match on that.\n\nRemember u need not make system call, but this following code compiles to sufficient commands in Java class file, and JVM runtime machine will execute that instructions and makes system calls depending on OS and Environment, on behalf of user and returs the results to the hash/buffer/stack area of JVM used by that class-file/code under running. And other important thing is that there is no eazy and free way for pattern match. You might want to write your own patten matching if it were simple patterns.\n\n\nhttp://javaalmanac.com/egs/java.io/GetFiles.html?l=rel\n\n\nFor using Java's Pattern matching, u might want to do this. But for your case of searching executables, just compare last 4 characters and if it matches ".exe" then u r good to go.\n\nhttp://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
484095
Maybe you need to download Java. It's free. Go to:\nhttp://www.java.com/en/
1818
try opening it with microsoft word. right click on the file and choose open with and then choose word or a the program that you think created the file.
101619
They're not that hard to write. You can use any text editor, such as notepad. Search your computer for "*.inf" and that will bring up all the inf files on your hard drive. Open a few with notepad to get an idea of what they should look like. Then try it out.\n\nThere are also programs out there that will do this for you. I've never used them, but here is one I found:\nhttp://www.karenware.com/powertools/ptautorun.asp
572725
What do you mean by codes? Are you using something like HTML or a programming language like C++ or Java. \n\nIf you are using a programming language you usually have to save the file with a certain extension like .cpp or .java . Then you need to compile it with a specific compiler for the language you are using. This is usually done in a command prompt or a Dos prompt. You'll have to find documentation to find out how to do this with the compiler for your programming language. For example, if your using java you would use the command prompt enter 'javac -classpath "yourFileDirectory" yourFileName.java' (not including the 's) .\n\nIf you are using something like HTML then all you need to do is save the file as .html and the web browser interprets it when you open it with your browser.\n\nOr maybe you should just talk to your teacher, at least to find out what language you're supposed to be using.
955560
Check up the java online tutorial from sun:-\nhttp://java.sun.com/docs/books/tutorial/\n\nYou can also check the following sites for other java related documents / ebooks:-\nhttp://www.freecomputerbooks.com/\nhttp://33367.com/
1088217
You need to save them as individual files\ngo to \nFile > Save As\nand select the *.mht from file types\nyou can send this file (Web page) as attachment\n\nXLMan
198260
Opening a file either means executing it or executing the application that uses the file. If the file is a system file then it may contain binary information for the operating system. You could open it as a text file but some of the binary data would not display as ascii characters. There are programs that will display a file as hex characters but that probably is not going to help you.
879351
For the starters you should use a simple notepad or textpad or edit plus as editors. Installing and using a fancy IDE will take the focus off learning and you will end up struggling with features of IDE. Once you have grasped the concepts, you can switch to Eclipse, or even download NetBeans from sun.java.com\n\nTo save your file as java, just put the file name in double quotes when saving e.g. "MyClass.java", or select '*.*' under file types when saving java file from notepad or any such basic editor.\n\nHTH.
522351
These are system files used in Simbian and Java applications, like games, and you really don't need to open those directly. The .jar files are Java archives and if you really need to open them, try WinZip or a similar file compression/decompression software, or try the link below. The .jar files contain bundles of Java information, kind of like a building block or component of your Java application. The .jad is usually an installer or a special file that tells the program how to install itself to your computer, and the .sis is similar but usually written in a different computer language.  Usually to "open" or "run" the three types of files you will simply click on the .exe or similar setup file that installs the program and the program itself will open and read each of the needed files as it installs to your computer. These files are usually left on the PC hard drive after the installation in case your computer gets damaged somehow and you have to repair or reinstall your application.
356595
visit this site\n\nhttp://java.sun.com/learning/tutorial/
328886
I do this alot for school papers so I think this might work for you. What I do is-\n1. Save the file in my documents or desktop\n2. Go to My Computer and click the disk (if it does not open in a different folder then just close it)\n3. Open My Documents in a different window while still having the My Computer window up as well\n4. Drag the word file onto the CD or into the folder\n It should say files waiting to be written or something like that and I hope this helps you
604118
This is an identical java code for your C++ code,\n\n1. create a filename, say HelloWorld.java,\n\n2. Write in following codes,\n\npublic class HelloWorld\n{\n      public static void main (String args[])\n      {\n           System.out.println("Hello World");\n      }\n}\n\n3. Save it and compile it. Then open the class file using java.
231724
not really sure how to do that.. \nbut try using a splitting program to join it\nhjsplit is a good one that i use to split and it joins files too. \n\nhttp://www.pcworld.com/downloads/file_description/0,fid,20360,00.asp
1174185
It's easy. You can use Shell command.\nexample: Shell "C:&#92;MyDocuments&#92;Program.exe"