开发者

reading a string from text file to be inserted into input

开发者 https://www.devze.com 2023-02-22 17:31 出处:网络
Lets say i has a file name \"abc.txt\"开发者_JAVA技巧 This file has three strings \" how are you \"

Lets say i has a file name "abc.txt"开发者_JAVA技巧

This file has three strings " how are you "

I would like to read the strings as "how are you"

and store it into a string word2 ?

How can i do it ?


try
{
    File file = new File("abc.txt");
    BufferedReader br = new BufferedReader(new FileReader(file));
    String word2 = br.readLine();
    br.close();
    //test:
    System.out.println(word2);
} catch (IOException e)
{
    // Something went wrong, eg: file not found
    e.printStackTrace();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消