當前位置: 首頁>>代碼示例>>Java>>正文


Java BufferedReader.ready方法代碼示例

本文整理匯總了Java中java.io.BufferedReader.ready方法的典型用法代碼示例。如果您正苦於以下問題:Java BufferedReader.ready方法的具體用法?Java BufferedReader.ready怎麽用?Java BufferedReader.ready使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.BufferedReader的用法示例。


在下文中一共展示了BufferedReader.ready方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.io.BufferedReader; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    BufferedReader conReader = new BufferedReader(new InputStreamReader(System.in));
    String fileName = conReader.readLine();
    //String fileName = "e:\\11.txt";
    conReader.close();

    BufferedReader fileReader = new BufferedReader(new FileReader(fileName));
    while (fileReader.ready()) {
        String line = fileReader.readLine();
        String[] lineWords = line.split("[\\p{P}\\s\\t\\n\\r]");
        int count = 0;
        for (String lineWord : lineWords) {
            for (String word : words) {
                if (lineWord.trim().equals(word))
                    count += 1;
            }
        }
        if (count == 2)
            System.out.println(line);
    }
    fileReader.close();
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:23,代碼來源:Solution.java

示例2: parseBody

import java.io.BufferedReader; //導入方法依賴的package包/類
private void parseBody(BufferedReader r) throws IOException {
    // Check if there is a body to read
    int contentLength = 0;
    List<String> lengthValuesArray = getHeaderValues(RtspHeader.CONTENT_LENGTH);
    if (lengthValuesArray != null && lengthValuesArray.size() >= 1) {
        String lengthString = lengthValuesArray.get(0);
        if (lengthString != null) {
            contentLength = Integer.valueOf(lengthString.trim());
        }
    }

    // Read the body
    String line;
    while (contentLength > body.length() && r.ready()) {
        line = r.readLine();
        if (line == null || line.isEmpty()) {
            break;
        }
        body += line + CRLF;
    }
}
 
開發者ID:devinbrown7,項目名稱:streaminglib,代碼行數:22,代碼來源:RtspMessage.java

示例3: PrintHelp

import java.io.BufferedReader; //導入方法依賴的package包/類
public static void PrintHelp()
{
    try
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(m6AMutationConsole.class.getResourceAsStream("/help.txt")));
        while(br.ready())
        {
            System.out.println(br.readLine());
        }
        br.close();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:YubinXieSYSU,項目名稱:m6ASNP,代碼行數:17,代碼來源:m6AMutationConsole.java

示例4: launchSqlScript

import java.io.BufferedReader; //導入方法依賴的package包/類
/** Lance un script sql
 * @param script
 */
@Transactional
private void launchSqlScript(String script){
	EntityManager em = entityManagerFactoryEcandidat.createEntityManager();
	em.getTransaction().begin();
	try
       {
           final InputStream inputStream = this.getClass().getResourceAsStream("/db/demo/"+script);
           final InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
           final BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
           while (bufferedReader.ready())
           {
           	Query query = em.createNativeQuery(bufferedReader.readLine());
           	query.executeUpdate();
           }

       }
       catch (Exception e)
       {
       	em.getTransaction().rollback();
   		em.close();
       }
	em.getTransaction().commit();
	em.close();
}
 
開發者ID:EsupPortail,項目名稱:esup-ecandidat,代碼行數:28,代碼來源:DemoController.java

示例5: main

import java.io.BufferedReader; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    String filename = args[0];

    BufferedReader file = new BufferedReader(new FileReader(filename));

    while (file.ready()) {
        String s = file.readLine();
        String[] strs = s.split(" ");
        addMap(strs[0], Double.parseDouble(strs[1]));
    }

    file.close();

    //show
    for (Map.Entry<String, Double> pair : map.entrySet()) {
        // Хотелось как в условии задачи отформатировать, а нет валидатор думает иначе.
        //System.out.println(String.format("%s %.2f", pair.getKey(), pair.getValue()));
        System.out.println(pair.getKey()+" "+pair.getValue()); // - Так проходит
    }
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:21,代碼來源:Solution.java

示例6: getNginxWorkerThreads

import java.io.BufferedReader; //導入方法依賴的package包/類
private static List<String> getNginxWorkerThreads(String containerId) {
    try {
        Process process = new ProcessBuilder("docker", "top", containerId, "-e", "-o", "pid,command").start();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        process.waitFor();
        List<String> allLines = new ArrayList<>();
        while (bufferedReader.ready()) {
            allLines.add(bufferedReader.readLine());
        }
        return allLines.stream()
                .filter((line) -> line.contains("nginx: worker process"))
                .map(line -> line.substring(0, line.indexOf("nginx")).trim())
                .collect(Collectors.toList());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:Kroger-Technology,項目名稱:Snow-Globe,代碼行數:18,代碼來源:ContainerUtil.java

示例7: loadNodeViewersFile

import java.io.BufferedReader; //導入方法依賴的package包/類
public List<String> loadNodeViewersFile(File selectedFile)
        throws IOException {
    List<String> result = new ArrayList<String>();
    if (defaultNodeViewersFile.exists()) {
        FileReader reader = new FileReader(selectedFile);
        try {
            BufferedReader buff = new BufferedReader(reader);
            try {
                while (buff.ready()) {
                    String line = buff.readLine();
                    if (line != null && line.length() > 0 && !line.startsWith("#")) {
                        result.add(line);
                    }
                }
            } finally {
                buff.close();
            }
        } finally {
            reader.close();
        }
    }
    return result;
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:24,代碼來源:ZooInspectorManagerImpl.java

示例8: loadGame

import java.io.BufferedReader; //導入方法依賴的package包/類
public static void loadGame(Country[] country, Player[] player) throws IOException{ 
	int i=0;
	FileReader infile=new FileReader("countryFile.txt");
	BufferedReader inputfile = new BufferedReader(infile);
	while(inputfile.ready()){ 
		country[i].setName(inputfile.readLine());
		country[i].setOwner(inputfile.readLine());
		country[i].setUnits(Integer.parseInt(inputfile.readLine()));
		//for(int i1=0;i1<63;i1++){ 
			//player[i].setCard[i1]();
		//}
	}
	inputfile.close();
	i=0;
	FileReader infile1=new FileReader("playerFile.txt");
	BufferedReader inputfile1 = new BufferedReader(infile1);
	while(inputfile1.ready()){ 
		player[i].setName(inputfile1.readLine());
		player[i].setCountry(Integer.parseInt(inputfile1.readLine()));
		
	}
	inputfile1.close();
}
 
開發者ID:SushiFish100,項目名稱:Final-ICS4U-ISP,代碼行數:24,代碼來源:mainGame.java

示例9: Chromosome

import java.io.BufferedReader; //導入方法依賴的package包/類
public Chromosome()
{
    try
    {
        ensemblToUcscMap = new HashMap();
        ucscToEnsemblMap = new HashMap(); 
        BufferedReader br = new BufferedReader(new InputStreamReader(Chromosome.class.getResourceAsStream("/chrMap.txt")));
        String strLine;
        String[] strArr;
        while(br.ready())
        {
            strLine = br.readLine();
            strArr = strLine.split("\t");
            ensemblToUcscMap.put(strArr[0], strArr[1]);
            ucscToEnsemblMap.put(strArr[1], strArr[0]);
        }
        br.close();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:YubinXieSYSU,項目名稱:m6ASNP,代碼行數:24,代碼來源:Chromosome.java

示例10: run

import java.io.BufferedReader; //導入方法依賴的package包/類
public void run() {//run method is called

    //Create message acceptor thread
    MessageAcceptor ma = new MessageAcceptor(clientSocket);//ma is a message acceptor and it takes in the clientSocket parameter
    new Thread(ma).start();//ma is a new thread and calls on the start method

    boolean running = true;//running is a true boolean
    try {
      while (running) {//try that while running is going, the pw will be a new socket from the output message
        if (running) {

          //Create a writer to pass messages from client to server
          PrintWriter pw = new PrintWriter(clientSocket.getOutputStream());

          //for reading input text
          BufferedReader msgTaker = new BufferedReader(new InputStreamReader(System.in));//msgTaker reads through the input stream
          System.out.println("");//print out a blank statement
          long end=System.currentTimeMillis()+1500;//end prints out the time +1500
          //non-blocking text input such that the user is given some time to enter a message
          String message = "";
          while((System.currentTimeMillis()<end)) {//while the time is less than the end
            if (msgTaker.ready())//if the buffered reader calls on the ready method
            message += msgTaker.readLine();//concatinate the following
          }

          //Message handling - non blocking
          if (message.equals("")) {//if the message is still blank
            System.out.println("No input on socket: " + clientSocket.getLocalAddress().toString());
          }//the following will print out
          else {
            System.out.println("The message is " + message + " on socket " + clientSocket.getLocalAddress().toString());
          }
          pw.println(message);

          //Check if client disconnected
          if (pw.checkError()) {//if the pw calls on the error message
            running = false;//running is false
            System.out.println("Cliented disconnected");
          }

          pw.flush();//flush out the print writer
        }
      }
      clientSocket.close();//close connection with the client socket
    } catch (IOException ioe) {//catch the following exception
      ioe.printStackTrace();//print stack trace
      System.out.println("Error connecting");//error messge will pop up
    }
  }
 
開發者ID:jeffreyshen19,項目名稱:Virtual-IoT-Server,代碼行數:50,代碼來源:WorkerRunnable.java

示例11: RandomForest

import java.io.BufferedReader; //導入方法依賴的package包/類
public RandomForest(File forestModelFile)
{
    try
    {
        BufferedReader br = new BufferedReader(new FileReader(forestModelFile));
        String strLine;
        String[] strArr;
        String treeStr = "";
        while(br.ready())
        {
            strLine = br.readLine();
            if(strLine.startsWith("@DataType"))
            {
                dataAttrTypeList = new ArrayList();
                strArr = strLine.split("\t");
                for(int i=1; i<strArr.length; i++)
                    dataAttrTypeList.add(Integer.parseInt(strArr[i]));
            }
            else if(strLine.startsWith("@Tree") || strLine.startsWith("@End"))
            {
                if(!treeStr.isEmpty())
                {
                    Tree tree = new Tree(treeStr, dataAttrTypeList);
                    treeList.add(tree);
                    treeStr = "";
                }
            }
            else
            {
                treeStr = treeStr + strLine + "\n";
            }
        }
        br.close();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }        
}
 
開發者ID:YubinXieSYSU,項目名稱:m6ASNP,代碼行數:40,代碼來源:RandomForest.java

示例12: leituraNextId

import java.io.BufferedReader; //導入方法依賴的package包/類
public static void leituraNextId () throws IOException {
	String linha = null;
	File arquivo = new File("IdProfessor.dat");
	FileReader fr = new FileReader(arquivo);
	BufferedReader br = new BufferedReader(fr);
	while( br.ready() ){
		linha = br.readLine();
	}
	nextId = Long.parseLong(linha);
	br.close();
	fr.close();
}
 
開發者ID:omniplatypus,項目名稱:Projeto-IP2,代碼行數:13,代碼來源:ProfessorDAO.java

示例13: nextLine

import java.io.BufferedReader; //導入方法依賴的package包/類
private String[] nextLine(BufferedReader reader) throws IOException {
	if (reader.ready()) {
		String line = reader.readLine();
		return line.split(delimiter);
	}
	return null;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:8,代碼來源:CSV.java

示例14: rewrite

import java.io.BufferedReader; //導入方法依賴的package包/類
public void rewrite() throws IOException {
	BufferedReader reader = new BufferedReader(this.reader);
	PrintWriter writer = new PrintWriter(this.writer);
	while (reader.ready()) {
		String line = reader.readLine();
		line = pattern.matcher(line).replaceAll(rewrite);
		writer.println(line);
	}
	writer.close();
	reader.close();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:12,代碼來源:RewriteMessages.java

示例15: largeFileIO

import java.io.BufferedReader; //導入方法依賴的package包/類
private void largeFileIO(File inputFile, int launch) throws IOException, InterruptedException {
    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(inputFile));
    BufferedReader in = new BufferedReader(new InputStreamReader(bis, "utf-8"), 1 * 1024 * 1024);// 1M緩存
    Long lineFlag = 0L;
    while (in.ready()) {
        if (lineFlag % launch == 0)
            Thread.sleep(100);
        String line = in.readLine();
        BufferQueue.produce(line);
        lineFlag++;
    }
    in.close();
}
 
開發者ID:V-I-C-T-O-R,項目名稱:DataM,代碼行數:14,代碼來源:FileStream.java


注:本文中的java.io.BufferedReader.ready方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。