Java reads local file contents

Source: Internet
Author: User

1. To have a bar chart format file called Test under the F-disk,

Java code
  1. Package test;
  2. Import Java.io.BufferedReader;
  3. Import Java.io.File;
  4. Import Java.io.FileReader;
  5. Public class Readerfile {
  6. public static void Main (string[] args) throws Exception {
  7. String fileName = "F://test.txt";
  8. File File = new file (FileName);
  9. if (!file.exists ()) {
  10. System.out.println ("File not exist");
  11. }
  12. FileReader FileReader = new FileReader (file);
  13. BufferedReader Breader = new BufferedReader (FileReader);
  14. String tempstring = null;
  15. While ((tempstring = Breader.readline ()) = null) {
  16. System.out.println (tempstring);
  17. }
  18. Breader.close ();
  19. Filereader.close ();
  20. }
  21. }
Package Test;import Java.io.bufferedreader;import Java.io.file;import Java.io.filereader;public class ReaderFile { public static void Main (string[] args) throws Exception {String fileName = "F://test.txt"; File File = new file (fileName), if (!file.exists ()) {System.out.println ("File not Exist");} FileReader FileReader = new FileReader (file); BufferedReader breader = new BufferedReader (FileReader); String tempstring = Null;while ((tempstring = Breader.readline ()) = null) {System.out.println (tempstring);} Breader.close (); Filereader.close ();}}

Java enterprise-Class generic rights security framework source SPRINGMVC MyBatis or Hibernate+ehcache Shiro Druid Bootstrap HTML5

"Java Framework source code download"

Java reads local file contents

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.