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


Java BufferedReader.readLine方法代码示例

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


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

示例1: obterDadosBD

import java.io.BufferedReader; //导入方法依赖的package包/类
public static void obterDadosBD() throws IOException{
    try {
        FileReader conf = new FileReader("config.txt");
        BufferedReader lerArq = new BufferedReader(conf);
        ConnectionFactory.DRIVER = lerArq.readLine();
        ConnectionFactory.URL = lerArq.readLine();
        ConnectionFactory.USER = lerArq.readLine();
        ConnectionFactory.PASS = lerArq.readLine();
        conf.close();
        
    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null,"Erro ao abrir o arquivo config.txt");
    }
    
   
}
 
开发者ID:carlinhosxxp,项目名称:RhydoJudge,代码行数:17,代码来源:ConnectionFactory.java

示例2: read

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * Read invalid JSON format.
 */
protected void read(final ProtocolFactory protocols, final Local file) throws AccessDeniedException {
    try {
        BufferedReader in = new BufferedReader(new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8")));
        try {
            String l;
            while((l = in.readLine()) != null) {
                Matcher array = Pattern.compile("\\[(.*?)\\]").matcher(l);
                while(array.find()) {
                    Matcher entries = Pattern.compile("\\{(.*?)\\}").matcher(array.group(1));
                    while(entries.find()) {
                        final String entry = entries.group(1);
                        this.read(protocols, entry);
                    }
                }
            }
        }
        finally {
            IOUtils.closeQuietly(in);
        }
    }
    catch(IOException e) {
        throw new AccessDeniedException(e.getMessage(), e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:28,代码来源:FireFtpBookmarkCollection.java

示例3: main

import java.io.BufferedReader; //导入方法依赖的package包/类
public static void main(String ... ags)throws Exception
{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(in.readLine());
	for(int i=0;i<n;i++)
	{
		StringTokenizer tk = new StringTokenizer(in.readLine());
		int a = Integer.parseInt(tk.nextToken());
		int b = Integer.parseInt(tk.nextToken());
		int c = Integer.parseInt(tk.nextToken());
		int sum=a+b;
		System.out.print(sum +" ");
		for(int j=1;j<c;j++)
		{
			sum = sum+(power(j)*b);
			System.out.print(sum + " ");
		}
		System.out.println();
	}
}
 
开发者ID:hell-sing,项目名称:hacker-rank,代码行数:21,代码来源:Java_loops_2.java

示例4: loadDefinition

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * Load the definition file and parse each of the sections
 * 
 * @param def The location of the definitions file
 * @param trans The color to be treated as transparent
 * @throws SlickException Indicates a failure to read or parse the definitions file
 * or referenced image.
 */
private void loadDefinition(String def, Color trans) throws SlickException {
	BufferedReader reader = new BufferedReader(new InputStreamReader(ResourceLoader.getResourceAsStream(def)));

	try {
		image = new Image(basePath+reader.readLine(), false, filter, trans);
		while (reader.ready()) {
			if (reader.readLine() == null) {
				break;
			}
			
			Section sect = new Section(reader);
			sections.put(sect.name, sect);
			
			if (reader.readLine() == null) {
				break;
			}
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to process definitions file - invalid format?", e);
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:31,代码来源:PackedSpriteSheet.java

示例5: makeMap

import java.io.BufferedReader; //导入方法依赖的package包/类
public static void makeMap() {
	try {
		InputStream is = EtFuturum.class.getResourceAsStream("/assets/OceanMonument.txt");
		BufferedReader br = new BufferedReader(new InputStreamReader(is));

		String s;
		while ((s = br.readLine()) != null) {
			String[] data = s.split("-");
			data[0] = data[0].trim();
			data[0] = data[0].substring(1, data[0].length() - 1);

			data[1] = data[1].trim();

			String[] coords = data[0].split(",");

			WorldCoord key = new WorldCoord(Integer.parseInt(coords[0].trim()), Integer.parseInt(coords[1].trim()), Integer.parseInt(coords[2].trim()));
			int value = Integer.parseInt(data[1]);

			map.put(key, value);
		}

		br.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:27,代码来源:OceanMonument.java

示例6: main

import java.io.BufferedReader; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    while (true) {
        String name = reader.readLine();
        if (name.isEmpty()) break;

        int age = Integer.parseInt(reader.readLine());
        int weight = Integer.parseInt(reader.readLine());
        int tailLength = Integer.parseInt(reader.readLine());

        Cat cat = new Cat(name, age, weight, tailLength);
        CATS.add(cat);
    }

    printList();
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:18,代码来源:Solution.java

示例7: getReceive

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * 获取回复消息
 * 
 * @param con
 * @return
 * @throws IOException
 */
private static String getReceive(HttpURLConnection con) throws IOException {
	InputStream is = null;
	try {
		is = con.getInputStream();
		BufferedReader br = new BufferedReader(new InputStreamReader(is,
				defaulEncoding));
		StringBuffer sb = new StringBuffer();
		String line;
		while ((line = br.readLine()) != null)
			sb.append(line);
		return sb.toString();
	} finally {
		if (null != is)
			is.close();
	}
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:24,代码来源:HTTPD.java

示例8: getParameter

import java.io.BufferedReader; //导入方法依赖的package包/类
public static <T> T getParameter(HttpServletRequest request, Class<T> cls) {
	String str, wholeStr = "";
	try {
		BufferedReader br = request.getReader();
		while ((str = br.readLine()) != null) {
			wholeStr += str;
		}
		if (StringUtils.isNotBlank(wholeStr)) {
			logger.info("request===>" + wholeStr);
               request.setAttribute("iBase4J.Parameters", wholeStr);
			return InstanceUtil.parse(wholeStr, cls);
		}
	} catch (Exception e) {
		logger.error("", e);
	}
	logger.info("request===>" + JSON.toJSONString(request.getParameterMap()));
	return Request2ModelUtil.covert(cls, request);
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:19,代码来源:WebUtil.java

示例9: readProcessStreamImpl

import java.io.BufferedReader; //导入方法依赖的package包/类
private static void readProcessStreamImpl(final InputStream stream, boolean remoteStream,  final LineProcessor lineProcessor) throws IOException {
    if (stream == null) {
        lineProcessor.reset();
        lineProcessor.close();
    } else {
        lineProcessor.reset();
        final BufferedReader br = getReader(stream, remoteStream);
        try {
            String line;
            while ((line = br.readLine()) != null) {
                lineProcessor.processLine(line);
            }
        } finally {
            lineProcessor.close();
            if (br != null) {
                br.close();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProcessUtils.java

示例10: read

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * Read the contents of the file indicated by fileName
 */
public static String read(InputStream is) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();
    while (br.ready()) {
        String line = br.readLine();
        sb.append("\n");
        sb.append(line);
    }
    String data = sb.toString();
    return data;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:15,代码来源:FileIO.java

示例11: run

import java.io.BufferedReader; //导入方法依赖的package包/类
public void run() {
    try {
        System.out.println("Connected to " + s);
        BufferedReader is = new BufferedReader(new InputStreamReader(s
                .getInputStream()));
        String result;
        while ((result = is.readLine()) != null) {
            String timePercentCount[] = result.split(" ");
            if (timePercentCount.length != 5) {
                System.err.println("Got " + result + " from " + s
                        + " exitng.");
                throw new IOException(result);
            }
            long time = Long.parseLong(timePercentCount[0]);
            // int percent = Integer.parseInt(timePercentCount[1]);
            int count = Integer.parseInt(timePercentCount[2]);
            int errs = Integer.parseInt(timePercentCount[3]);
            if (errs > 0) {
                System.out.println(s + " Got an error! " + errs);
            }
            add(time, count, s);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        close();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:GenerateLoad.java

示例12: launchWordCount

import java.io.BufferedReader; //导入方法依赖的package包/类
static String launchWordCount(URI fileSys, JobConf conf, String input,
                              int numMaps, int numReduces) 
throws IOException {
  final Path inDir = new Path("/testing/wc/input");
  final Path outDir = new Path("/testing/wc/output");
  FileSystem fs = FileSystem.get(fileSys, conf);
  configureWordCount(fs, conf, input, numMaps, numReduces, inDir, outDir);
  JobClient.runJob(conf);
  StringBuffer result = new StringBuffer();
  {
    Path[] parents = FileUtil.stat2Paths(fs.listStatus(outDir.getParent()));
    Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
            new Utils.OutputFileUtils.OutputFilesFilter()));
    for(int i=0; i < fileList.length; ++i) {
      BufferedReader file = 
        new BufferedReader(new InputStreamReader(fs.open(fileList[i])));
      String line = file.readLine();
      while (line != null) {
        result.append(line);
        result.append("\n");
        line = file.readLine();
      }
      file.close();
    }
  }
  return result.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestMiniMRClasspath.java

示例13: readTxt

import java.io.BufferedReader; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public static void readTxt(String path2) throws Exception
{

	Reader reader = new FileReader(path2);;
	BufferedReader bufr = new BufferedReader(reader);

	StringBuffer buf = new StringBuffer();
	String line = null;
	String s = null;
	int k = 0;
	while ((line = bufr.readLine()) != null)
	{

		if (line.contains("答案"))
		{
			arr1[k] = line;
			line = "aaaaa";
			k++;
		}
		buf.append(line + "\r\n");
	}
	s = buf.toString();
	arr2 = s.split("aaaaa");
	for (int j = 0; j < arr2.length; j++)
	{
		arr[j] = arr2[j];
	}
	bufr.close();
}
 
开发者ID:JAVA201708,项目名称:Homework,代码行数:31,代码来源:ObjectStreamDemo.java

示例14: readFromFile

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * Ask a file for the username and password.
 */
private void readFromFile() {
   try {
      FileReader fr = new FileReader(this.credentials);
      BufferedReader br = new BufferedReader(fr);
      this.username = br.readLine();
      this.password = br.readLine();
      br.close();
      fr.close();
   }
   catch (Exception e) {
      this.username = "";
      this.password = "";
   }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:18,代码来源:UsernamePassword.java

示例15: getNextLine

import java.io.BufferedReader; //导入方法依赖的package包/类
private String getNextLine(BufferedReader br) {
    try {
        return br.readLine();
    }
    catch (Exception e) {
        return null;
    }

}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:10,代码来源:LoadableProperties.java


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