当前位置: 首页>>代码示例>>Java>>正文


Java DataInputStream.readLine方法代码示例

本文整理汇总了Java中java.io.DataInputStream.readLine方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.readLine方法的具体用法?Java DataInputStream.readLine怎么用?Java DataInputStream.readLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataInputStream的用法示例。


在下文中一共展示了DataInputStream.readLine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.io.DataInputStream; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException
{
    RSA rsa = new RSA();
    DataInputStream in = new DataInputStream(System.in);
    String teststring;
    System.out.println("Enter the plain text:");
    teststring = in.readLine();
    System.out.println("Encrypting String: " + teststring);
    System.out.println("String in Bytes: "
            + bytesToString(teststring.getBytes()));
    // encrypt
    byte[] encrypted = rsa.encrypt(teststring.getBytes());
    // decrypt
    byte[] decrypted = rsa.decrypt(encrypted);
    System.out.println("Decrypting Bytes: " + bytesToString(decrypted));
    System.out.println("Decrypted String: " + new String(decrypted));
}
 
开发者ID:hacktoberfest17,项目名称:programming,代码行数:19,代码来源:RSA.java

示例2: login

import java.io.DataInputStream; //导入方法依赖的package包/类
public String login(String username, String password) throws MalformedURLException, IOException {
    URL url = new URL("https://authserver.mojang.com/authenticate"); //Mojang正版验证服务器
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(); //创建连接
    /**
     * 连接参数设置
     */
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.setRequestMethod("POST");
    conn.setUseCaches(false);
    conn.setInstanceFollowRedirects(true);
    conn.setConnectTimeout(20000);
    conn.setReadTimeout(300000);
    conn.setRequestProperty("Content-Type", "application/json");

    conn.connect(); //连接服务器
    DataOutputStream out = new DataOutputStream(conn.getOutputStream()); //创建标准输出系统
    String json = "{\"agent\": {\"name\": \"Minecraft\",\"version\": 1},\"username\": \"" + username
            + "\",\"password\": \"" + password + "\"}"; //需要发送的信息
    out.writeBytes(json); //发送信息
    if (conn.getResponseCode() == 403) { //如果服务器返回403错误
        return "403"; //返回403
    }
    DataInputStream in = new DataInputStream(conn.getInputStream()); //如果正常
    return in.readLine(); //返回服务器结果
}
 
开发者ID:Prisma-illya,项目名称:PMCL,代码行数:27,代码来源:MojangAuth.java

示例3: EventReader

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Create a new Event Reader
 * @param in
 * @throws IOException
 */
@SuppressWarnings("deprecation")
public EventReader(DataInputStream in) throws IOException {
  this.in = in;
  this.version = in.readLine();
  
  if (!EventWriter.VERSION.equals(version)) {
    throw new IOException("Incompatible event log version: "+version);
  }

  Schema myschema = new SpecificData(Event.class.getClassLoader()).getSchema(Event.class);
  this.schema = Schema.parse(in.readLine());
  this.reader = new SpecificDatumReader(schema, myschema);
  this.decoder = DecoderFactory.get().jsonDecoder(schema, in);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:EventReader.java

示例4: canRunRootCommands

import java.io.DataInputStream; //导入方法依赖的package包/类
public static boolean canRunRootCommands()
{
    boolean retval = false;
    Process suProcess;

    try
    {
        suProcess = Runtime.getRuntime().exec("su");

        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
        DataInputStream osRes = new DataInputStream(suProcess.getInputStream());

        if (null != os && null != osRes)
        {
            // Getting the id of the current user to check if this is root
            os.writeBytes("id\n");
            os.flush();
            String currUid = osRes.readLine();
            Log.d("Receive", currUid);
            boolean exitSu = false;
            if (null == currUid)
            {
                retval = false;
                exitSu = false;
                Log.d("ROOT", "Can't get root access or denied by user");
            }
            else if (true == currUid.contains("uid=0"))
            {
                retval = true;
                exitSu = true;
                Log.d("ROOT", "Root access granted");
            }
            else
            {
                retval = false;
                exitSu = true;
                Log.d("ROOT", "Root access rejected: " + currUid);
            }

            if (exitSu)
            {
                os.writeBytes("exit\n");
                os.flush();
            }
        }
    }
    catch (Exception e)
    {
        // Can't get root !
        // Probably broken pipe exception on trying to write to output stream (os) after su failed, meaning that the device is not rooted

        retval = false;
        Log.d("ROOT", "Root access rejected [" + e.getClass().getName() + "] : " + e.getMessage());
    }

    return retval;
}
 
开发者ID:qwe321qwe321qwe321,项目名称:NFC-UID-Emulator,代码行数:58,代码来源:ExecuteAsRoot.java

示例5: canRunRootCommands

import java.io.DataInputStream; //导入方法依赖的package包/类
public static boolean canRunRootCommands() {  
    boolean retval = false;  
    Process suProcess;  

    try {  
        suProcess = Runtime.getRuntime().exec("su");  

        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());  
        DataInputStream osRes = new DataInputStream(suProcess.getInputStream());  

        if (null != os && null != osRes) {  
            // Getting the id of the current user to check if this is root  
            os.writeBytes("id\n");  
            os.flush();  

            String currUid = osRes.readLine();  
            boolean exitSu = false;  
            if (null == currUid) {  
                retval = false;  
                exitSu = false;  
                Log.d("ROOT", "Can't get root access or denied by user");  
            } else if (true == currUid.contains("uid=0")) {  
                retval = true;  
                exitSu = true;  
                Log.d("ROOT", "Root access granted");  
            } else {  
                retval = false;  
                exitSu = true;  
                Log.d("ROOT", "Root access rejected: " + currUid);  
            }  

            if (exitSu) {  
                os.writeBytes("exit\n");  
                os.flush();  
            }  
        }  
    } catch (Exception e) {  
        // Can't get root !  
        // Probably broken pipe exception on trying to write to output  
        // stream after su failed, meaning that the device is not rooted  

        retval = false;  
        Log.d("ROOT",  
  "Root access rejected [" + e.getClass().getName() + "] : " + e.getMessage());  
    }  

    return retval;  
}
 
开发者ID:qq1198,项目名称:mtoolbox,代码行数:49,代码来源:root.java

示例6: canRunRootCommands

import java.io.DataInputStream; //导入方法依赖的package包/类
public static boolean canRunRootCommands()
{
    boolean retval = false;
    Process suProcess;

    try
    {
        suProcess = Runtime.getRuntime().exec("su");

        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
        DataInputStream osRes = new DataInputStream(suProcess.getInputStream());

        if (null != os && null != osRes)
        {
            // Getting the id of the current user to check if this is root
            os.writeBytes("id\n");
            os.flush();

            String currUid = osRes.readLine();
            boolean exitSu = false;
            if (null == currUid)
            {
                retval = false;
                exitSu = false;
                Log.d("ROOT", "Can't get root access or denied by user");
            }
            else if (true == currUid.contains("uid=0"))
            {
                retval = true;
                exitSu = true;
                Log.d("ROOT", "Root access granted");
            }
            else
            {
                retval = false;
                exitSu = true;
                Log.d("ROOT", "Root access rejected: " + currUid);
            }

            if (exitSu)
            {
                os.writeBytes("exit\n");
                os.flush();
            }
        }
    }
    catch (Exception e)
    {
        // Can't get root !
        // Probably broken pipe exception on trying to write to output stream (os) after su failed, meaning that the device is not rooted

        retval = false;
        Log.d("ROOT", "Root access rejected [" + e.getClass().getName() + "] : " + e.getMessage());
    }

    return retval;
}
 
开发者ID:aario,项目名称:killcamera,代码行数:58,代码来源:ExecuteAsRootBase.java

示例7: canRunRootCommands

import java.io.DataInputStream; //导入方法依赖的package包/类
public boolean canRunRootCommands()
{
    boolean retval = false;
    Process suProcess;

    try
    {
        suProcess = Runtime.getRuntime().exec("su");

        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
        DataInputStream osRes = new DataInputStream(suProcess.getInputStream());

        if (null != os && null != osRes)
        {
            // Getting the id of the current user to check if this is root
            os.writeBytes("id\n");
            os.flush();

            String currUid = osRes.readLine();
            boolean exitSu = false;
            if (null == currUid)
            {
                retval = false;
                exitSu = false;
                Log.d("ROOT", "Can't get root access or denied by user");
            }
            else if (true == currUid.contains("uid=0"))
            {
                retval = true;
                exitSu = true;
                Log.d("ROOT", "Root access granted");
            }
            else
            {
                retval = false;
                exitSu = true;
                Log.d("ROOT", "Root access rejected: " + currUid);
            }

            if (exitSu)
            {
                os.writeBytes("exit\n");
                os.flush();
            }
        }
    }
    catch (Exception e)
    {
        // Can't get root !
        // Probably broken pipe exception on trying to write to output stream (os) after su failed, meaning that the device is not rooted

        retval = false;
        Log.d("ROOT", "Root access rejected [" + e.getClass().getName() + "] : " + e.getMessage());
    }

    return retval;
}
 
开发者ID:Pablito2020,项目名称:Recovery_Changer_Krillin,代码行数:58,代码来源:ExecuteAsRootBase.java


注:本文中的java.io.DataInputStream.readLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。