当前位置: 首页>>代码示例>>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;未经允许,请勿转载。