Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package helloworldproject;
- import java.io.*;
- /**
- *
- * @author Stefan
- */
- public class HelloWorldProject {
- public static String ReadTextFile(String FileName){
- String returnValue = "";
- FileReader file = null;
- try{
- file = new FileReader(FileName);
- BufferedReader reader = new BufferedReader(file);
- String line = "";
- while ((line = reader.readLine()) != null){
- returnValue += line + "\n";
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- if (file != null){
- try {
- file.close();
- } catch (IOException e){
- // ignore
- }
- }
- }
- return returnValue;
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- String Desktop = System.getProperty("user.home") + "/Desktop";
- System.out.println(ReadTextFile(Desktop + "/text.txt"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement