什么可以用来代替android studio中的readLine()

时间:2017-04-13 18:22:19

标签: android deprecated readline

'的readLine()'被弃用的人少了...
这是我在android studio中使用readLine()时显示的错误。可以使用什么

    DataInputStream in = new DataInputStream(client.getInputStream());
                String line = null;
                while((line = in.*readLine()*) != null)
                {
                    msg = msg + "\n Client : " + line;
                    handler.post(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            chat.setText(msg);
                        }
                    });
                }
                in.close();

1 个答案:

答案 0 :(得分:1)

要按行读取,请尝试BufferedReader:

BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));