當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。