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


Java BufferedReader類代碼示例

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


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

示例1: decompress

import java.io.BufferedReader; //導入依賴的package包/類
public static String decompress(byte[] compressed) {
    if(compressed==null) return null;
    ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
    try {
        GZIPInputStream gis = new GZIPInputStream(bis);
        BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
        StringBuilder sb = new StringBuilder();
        String line;
        while((line = br.readLine()) != null) {
            sb.append(line);
        }
        br.close();
        gis.close();
        bis.close();
        return sb.toString();
    }catch (IOException ex){
        ex.printStackTrace();
    }
    return null;
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:21,代碼來源:BundleUtils.java

示例2: getQueryByRowID

import java.io.BufferedReader; //導入依賴的package包/類
public String getQueryByRowID(int rowID, String pno) {
    String filePath = SysConfig.Catalog_Project + "pipeline/" + pno + "/workload.txt";
    String query = null;
    try (BufferedReader reader = InputFactory.Instance().getReader(filePath)) {
        String line = reader.readLine();
        String[] splits;
        int i = 0;
        while ((line = reader.readLine()) != null) {
            if (i == rowID) {
                splits = line.split("\t");
                query = splits[2];
                break;
            }
            i++;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return query;
}
 
開發者ID:dbiir,項目名稱:rainbow,代碼行數:21,代碼來源:RwMain.java

示例3: runCMD

import java.io.BufferedReader; //導入依賴的package包/類
public void runCMD(String command) throws Exception {
    Process p = Runtime.getRuntime().exec("cmd /c cmd.exe /c " + command + " exit");//cmd /c dir   執行完dir命令後關閉窗口。


    //runCMD_bat("C:\\1.bat");/調用
    //Process p = Runtime.getRuntime().exec("cmd /c start cmd.exe /c " + path + " exit");//顯示窗口 打開一個新窗口後執行dir指令(原窗口會關閉)


    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String readLine = br.readLine();
    while (readLine != null) {
        readLine = br.readLine();
        System.out.println(readLine);
    }
    if (br != null) {
        br.close();
    }
    p.destroy();
    p = null;
}
 
開發者ID:1135,項目名稱:EquationExploit,代碼行數:21,代碼來源:Exploit.java

示例4: main

import java.io.BufferedReader; //導入依賴的package包/類
public static void main(String ... ags)throws IOException
{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(in.readLine());
	StringTokenizer tk = new StringTokenizer(in.readLine());
	TreeSet<Integer> ts = new TreeSet<>();
	for(int i=0;i<n;i++)
	{
		int val = Integer.parseInt(tk.nextToken());
		if(val%2 != 0)
			ts.add(i);
	}
	if(ts.size()%2 != 0)
		System.out.println("NO");
	else
	{
		int res = 0;
		while(ts.size() != 0)
		{
			int a = ts.pollFirst();
			int b = ts.pollFirst();
			res += (b-a-1)*2 + 2;
		}
		System.out.println(res);
	}
}
 
開發者ID:hell-sing,項目名稱:hacker-rank,代碼行數:27,代碼來源:Fair_Rations.java

示例5: getURL

import java.io.BufferedReader; //導入依賴的package包/類
public static String getURL(String surl) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    System.setProperty("java.net.preferIPv4Addresses", "true");
    System.setProperty("java.net.preferIPv6Addresses", "false");
    System.setProperty("validated.ipv6", "false");
    String fullString = "";
    try {

        URL url = new URL(surl);
        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            fullString += line;
        }
        reader.close();
    } catch (Exception ex) {
        //showDialog("Verbindungsfehler.",parent);
    }

    return fullString;
}
 
開發者ID:LV-Crew,項目名稱:Adblocker-for-Android,代碼行數:24,代碼來源:MainActivity.java

示例6: doPostRequest

import java.io.BufferedReader; //導入依賴的package包/類
private void doPostRequest(String destination, String parms) throws IOException {
    URL url = new URL(destination);
    String response = "";
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setReadTimeout(10000);
    conn.setConnectTimeout(15000);
    conn.setRequestMethod("POST");
    conn.setDoInput(true);
    conn.setDoOutput(true);

    OutputStream os = conn.getOutputStream();
    BufferedWriter writer = new BufferedWriter(
            new OutputStreamWriter(os, "UTF-8"));
    writer.write(parms);
    writer.flush();
    writer.close();
    os.close();

    conn.connect();
    int responseCode = conn.getResponseCode();

    if (responseCode == HttpURLConnection.HTTP_OK) {
        String line;
        BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
        while ((line=br.readLine()) != null) {
            response+=line;
        }
    }
    else {
        response="";

    }
}
 
開發者ID:jsparber,項目名稱:CaptivePortalAutologin,代碼行數:34,代碼來源:CaptivePortalLoginActivity.java

示例7: process

import java.io.BufferedReader; //導入依賴的package包/類
private static void process(String urlstring) {
  try {
    URL url = new URL(urlstring);
    System.out.println("Connecting to " + url);
    URLConnection connection = url.openConnection();
    connection.connect();

    BufferedReader in = new BufferedReader(new InputStreamReader(
        connection.getInputStream()));
    for(String line; (line = in.readLine()) != null; )
      if (line.startsWith(MARKER)) {
        System.out.println(TAG.matcher(line).replaceAll(""));
      }
    in.close();
  } catch (IOException ioe) {
    System.err.println("" + ioe);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:LogLevel.java

示例8: loadBlacklist

import java.io.BufferedReader; //導入依賴的package包/類
private  java.util.HashMap loadBlacklist()
{
    java.util.HashMap<String,String> map = new java.util.HashMap<String,String>();
    try {
        java.io.BufferedReader input = new java.io.BufferedReader( new java.io.FileReader( BLACKLISTFILE ) );
        java.lang.String line = "";
        while ((line = input.readLine()) != null) {
            if (false) {
                map.put( line, line );
            }
        }
        input.close();
    } catch ( java.io.IOException e ) {
        System.out.println( "File is not found" );
    }
    return map;
}
 
開發者ID:terdel-ninja,項目名稱:REH2017Anthony,代碼行數:18,代碼來源:GPMSPasswordValidation.java

示例9: loadBlacklist

import java.io.BufferedReader; //導入依賴的package包/類
private  java.util.HashMap loadBlacklist()
{
    java.util.HashMap<String,String> map = new java.util.HashMap<String,String>();
    try {
        java.io.BufferedReader input = new java.io.BufferedReader( new java.io.FileReader( BLACKLISTFILE ) );
        java.lang.String line = "";
        while ((line = input.readLine()) != null) {
            if (line.length() > 7) {
                map.put( line, line );
            }
        }
        input.close();
    } catch ( java.io.IOException e ) {
        System.out.println( "File is not found" );
    }
    return map;
}
 
開發者ID:terdel-ninja,項目名稱:REH2017Anthony,代碼行數:18,代碼來源:GPMSPasswordValidation.java

示例10: initConfig

import java.io.BufferedReader; //導入依賴的package包/類
private void initConfig() throws IOException {
		// generate temporary files
		tmpDir = createTempDirectory();
		ClassLoader classLoader = EmbeddedCassandraService.class.getClassLoader();
		InputStream in = getClass().getResourceAsStream("/cassandra.yaml");
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		File tmp = new File(tmpDir.getAbsolutePath() + File.separator + "cassandra.yaml");

//		Assert.assertTrue(tmp.createNewFile());

		BufferedWriter b = new BufferedWriter(new FileWriter(tmp));
		//copy cassandra.yaml; inject absolute paths into cassandra.yaml
		String line;
		while ((line = reader.readLine()) != null) {
			line = line.replace("$PATH", "'" + tmp.getParentFile());
			b.write(line + "\n");
			b.flush();
		}

		// Tell cassandra where the configuration files are.
		// Use the test configuration file.
		System.setProperty(CAS_CONFIG_PROP, tmp.getAbsoluteFile().toURI().toString());

		LOG.info("Embedded Cassasndra config generated at [{}]", System.getProperty(CAS_CONFIG_PROP));
	}
 
開發者ID:mcfongtw,項目名稱:flink-cassandra-connector-examples,代碼行數:26,代碼來源:EmbeddedCassandraService.java

示例11: main

import java.io.BufferedReader; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    //напишите тут ваш код

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int i = 0;
    int count = 0;
    double sum = 0;
    while (i != -1) {
        i = Integer.parseInt(br.readLine());
        sum += i;
        count++;
    }
    double avg = (sum+1) / (count-1);
    System.out.println(avg);
}
 
開發者ID:avedensky,項目名稱:JavaRushTasks,代碼行數:17,代碼來源:Solution.java

示例12: getNotCommentedLines

import java.io.BufferedReader; //導入依賴的package包/類
private static List<String> getNotCommentedLines(InputStream excludedClassesStream) {
    List<String> list = new ArrayList<>();

    try(BufferedReader br = new BufferedReader(new InputStreamReader(excludedClassesStream))){

        String line;
        while ((line = br.readLine()) != null) {
            String element = line.trim();
            if(! element.startsWith("//") && !element.isEmpty()) {
                list.add(element);
            }
        }
    } catch(IOException e) {
        throw new RuntimeException(e);
    }

    return Collections.unmodifiableList(list);
}
 
開發者ID:EMResearch,項目名稱:EvoMaster,代碼行數:19,代碼來源:ClassesToExclude.java

示例13: makeContent

import java.io.BufferedReader; //導入依賴的package包/類
/**
 * 得到響應對象
 * 
 * @param urlConnection
 * @return 響應對象
 * @throws IOException
 */
private HttpRespons makeContent(String urlString, HttpURLConnection urlConnection) throws IOException {
	HttpRespons httpResponser = new HttpRespons();
	try {
		InputStream in = urlConnection.getInputStream();
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,
				Charset.forName(this.defaultContentEncoding)));
		httpResponser.contentCollection = new Vector<String>();
		StringBuffer temp = new StringBuffer();
		String line = bufferedReader.readLine();
		while (line != null) {
			httpResponser.contentCollection.add(line);
			temp.append(line).append("");
			line = bufferedReader.readLine();
		}
		bufferedReader.close();

		String ecod = urlConnection.getContentEncoding();
		if (ecod == null)
			ecod = this.defaultContentEncoding;

		httpResponser.urlString = urlString;

		httpResponser.defaultPort = urlConnection.getURL().getDefaultPort();
		httpResponser.file = urlConnection.getURL().getFile();
		httpResponser.host = urlConnection.getURL().getHost();
		httpResponser.path = urlConnection.getURL().getPath();
		httpResponser.port = urlConnection.getURL().getPort();
		httpResponser.protocol = urlConnection.getURL().getProtocol();
		httpResponser.query = urlConnection.getURL().getQuery();
		httpResponser.ref = urlConnection.getURL().getRef();
		httpResponser.userInfo = urlConnection.getURL().getUserInfo();

		httpResponser.content = temp.toString();
		httpResponser.contentEncoding = ecod;
		httpResponser.code = urlConnection.getResponseCode();
		httpResponser.message = urlConnection.getResponseMessage();
		httpResponser.contentType = urlConnection.getContentType();
		httpResponser.method = urlConnection.getRequestMethod();
		httpResponser.connectTimeout = urlConnection.getConnectTimeout();
		httpResponser.readTimeout = urlConnection.getReadTimeout();

		return httpResponser;
	} catch (IOException e) {
		throw e;
	} finally {
		if (urlConnection != null)
			urlConnection.disconnect();
	}
}
 
開發者ID:butter-fly,項目名稱:belling-spring-rabbitmq,代碼行數:57,代碼來源:HttpRequester.java

示例14: extractEdges

import java.io.BufferedReader; //導入依賴的package包/類
/**
 * Reads in all the edges from the BRITE file and adds them to the given graph.
 * The required nodes have to present in the given graph.
 *
 * @param graph  graph to add the edges to
 * @param reader reader at the position to start
 * @throws IOException in case of an I/O error
 */
private static void extractEdges(Graph graph, BufferedReader reader) throws IOException {
    String line = reader.readLine();

    while (line != null && !line.isEmpty()) {
        // split the line into pieces and parse them separately
        String[] values = line.split("\t");
        if (values.length >= 9) {
            int id = Integer.parseInt(values[0]);
            int from = Integer.parseInt(values[1]);
            int to = Integer.parseInt(values[2]);
            float delay = Float.parseFloat(values[4]);
            float bandwidth = Float.parseFloat(values[5]);

            // get the source and destination nodes from the existing graph
            Router fromNode = graph.getRouter(from);
            Router toNode = graph.getRouter(to);
            if (fromNode != null && toNode != null) {
                // create the new edge object
                graph.createEdge(id, fromNode, toNode, delay, bandwidth);
            }
        }

        line = reader.readLine();
    }
}
 
開發者ID:emufog,項目名稱:emufog,代碼行數:34,代碼來源:BriteFormatReader.java

示例15: sessionAlreadyImported

import java.io.BufferedReader; //導入依賴的package包/類
public static boolean sessionAlreadyImported(File xmlImportFile, File xmlSessionFile) throws IOException {
	BufferedReader br1 = new BufferedReader(new FileReader(xmlSessionFile)); //sessionfile
	BufferedReader br2 = new BufferedReader(new FileReader(xmlImportFile)); //desktop import
	String s1, s2;
	
	s1 = br1.readLine();
	s2 = br2.readLine();
	s2 = br2.readLine();
	br2.mark(2000);;
	while(s1 != null) {		
		while (s1 != null && s2 != null && s1.equals(s2)) {
			s1 = br1.readLine();
			s2 = br2.readLine();
			if (s2 == null) {
				br1.close();
				br2.close();
				return true;
			}
		}
		br2.reset();
		s1 = br1.readLine();
	}
	br1.close();
	br2.close();
	return false;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:27,代碼來源:FilesUtil.java


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