bufferedreader

search for more blogs here

 

"Loops-Counters" posted by ~Ray
Posted on 2008-11-13 12:20:55

Java Help Java Help forum discussing all Java platforms - J2ME. J2SE and J2EE - as well as relevant standards. APIs and frameworks such as Swing. Servlets. JSPs. Applets. Struts. Spring. Hibernate. ANT. EJB and other Java-related topics. Hi. I started learning Java about 9 months ago and here is where it gets tricky for me. When I am learning loops and arrays. I do not need to buy more books or look at more tutorials because I have looked at hundreds of books tutorials and programs and at one point I had what I needed and then I didn't save-somewhere in the middle of the night last week. Many forums will not help only suggest different tutorials or books. I am close and I do want tips that push me in the right direction. One book I recommend is Big Java. Here is a program that does some of what I would like it to do it does not allow the user to input the sentence into an array and then input a character to search for that value. It's fairly simple to find a value when it's a number. I can write a simple program so far. But I feel I am missing many crucial elements. I want the program to allow the user input a sentence or several values (with a dialog box) then input the value to find in that sentence or group of numbers then the program totals the number of times the value is found. import java io.*;public class WordCount{private static void linecount(String fName. BufferedReader in) throws IOException{long numChar = 0;long numLine=0;long numWords = 0;String line;do{line = in readLine();if (line != null){numChar += line length();numWords += wordcount(line);numLine++;}}while(line != null);System out println("Enter Sentence: " + fName);System out println("Enter Character: " + fName);System out println("Number of characters in sentence: " + numChar);System out println("Number of words: " + numWords);System out println("Number of Lines: " + numLine);}private static void linecount(String fileName){BufferedReader in = null;try{FileReader fileReader = new FileReader(fileName);in = new BufferedReader(fileReader);linecount(fileName,in);}catch(IOException e){e printStackTrace();}}private static long wordcount(String line){long numWords = 0;int index = 0;boolean prevWhiteSpace = true;while(index < line length()){char c = line charAt(index++);boolean currWhiteSpace = Character isWhitespace(c);if(prevWhiteSpace && !currWhiteSpace){numWords++;}prevWhiteSpace = currWhiteSpace;}return numWords;}public static void main(String[] args){long numChar = 0;long numLine=0;String line;try{if (args length == 0){BufferedReader in = new BufferedReader(new InputStreamReader(System in));line = in readLine();numChar = line length();if (numChar != 0){numLine=1;}System out println("Number of characters in sentence: " + numChar);System out println("Number of words: " + wordcount(line));System out println("Number of lines: " + numLine);}else{for(int i = 0; i < args length; i++){linecount(args[i]);}}}catch(IOException e){e printStackTrace();}}} So you want to enter something like:Enter a sentence:=> "The quick brown fox jumped over the lazy dog"Then,Enter a character:=> "q"And what is it suppose to return? The placement in the sentence? Do spaces count? Would q be 4 or 5? What if there are more than one instance of the character in the sentence?Have I completely missed the point? Hi Sidewinder thanks and no you didn't miss the point. Yes the user is prompted to enter a sentence then prompted to enter a character within the sentence then the program outputs a number which is the number of times it finds that character. The program displays the number of times the character appears in the sentence. The program is searching the array for the character entered and returns the number of times it's found. Well you would store the inputed sentence as a string. Then you could call the toCharArray() method on the string which would convert the string into an array of characters so you can reference them by their index. Lets assume the inputed string is called str and the inputed character is called input2. The first thing you have to 'note' is that input2 is a string so you will have to convert that into a char. Once you have converted the input2 string to a char lets call that variable chr. You can then create a loop from 0 to str length() and check if str toCharArray()[i] is the same as chr. If it is increment a counter and start the loop again One thing this doesn't account for is the fact that 'H' and 'h' are different. So if you run this using 'h' it will return 1 but using 'H' it will return 0. Of course you can account for using other methods but this will get you started. Template Design © . All rights reserved. Powered by vBulletin® Version 3.7.2Copyright ©2000 - 2008. Jelsoft Enterprises Ltd. LinkBacks Enabled by 3.0.0

Forex Groups - Tips on Trading

Related article:
http://forum.codecall.net/java-help/4845-loops-counters.html

comments | Add comment | Report as Spam


"Basic Operations on Files" posted by ~Ray
Posted on 2008-03-12 23:12:43

                        /*FILE OPERATIONS*/                     System out println(”\n\tFILE OPERATION”);   System out println(”\t^^^^^^^^^^^^^^^^”);   System out println(”1. show a file”);   System out println(”2. Copy a file”);   System out println(”3. Delete a register”);   System out println(”say : Files in current Directory”);    System out print(”register ur choice  : “);    BufferedReader br=new BufferedReader(new InputStreamReader(System in));       BufferedReader br1=new BufferedReader(new InputStreamReader(System in));       System out print(”register the obtain register name :”);       src=br1 readLine();       fin=new FileInputStream(src);       System out println(”Content in obtain register is : “);      surprise(FileNotFoundException e)       System out println(”File not open”);       System out println(”Usage : To show a File “);        BufferedReader br1=new BufferedReader(new InputStreamReader(System in));        System out create(”Enter the obtain register name :”);        src=br1 readLine();        fin=new FileInputStream(src);       catch(FileNotFoundException e)        System out println(”Read file not open”);        BufferedReader br1=new BufferedReader(new InputStreamReader(System in));        System out create(”Enter the destination register name :”);        dest=br1 readLine();        fout=new FileOutputStream(dest);       catch(FileNotFoundException e)        System out println(”Write register not found”);       System out println(”Usage : write from source file to destination register”);       System out println(”1 file copied”);       System out println(”File error”);      BufferedReader b=new BufferedReader(new InputStreamReader(System in));      System out print(”register the file name to remove :”);      String Filename=b readLine();      File f=new File(Filename);      if(f exists() && f isFile())       System out println(”1 file deleted”);       System out println(”File not open”);      System out println(”Invalid choice…”);

Forex Groups - Tips on Trading

Related article:
http://bloggeo.org/programs/2007/11/09/basic-operations-on-files/

comments | Add comment | Report as Spam


"Basic Operations on Files" posted by ~Ray
Posted on 2008-03-12 23:12:43

                        /*register OPERATIONS*/                     System out println(”\n\tFILE OPERATION”);   System out println(”\t^^^^^^^^^^^^^^^^”);   System out println(”1. show a register”);   System out println(”2. Copy a register”);   System out println(”3. Delete a file”);   System out println(”Note : Files in current Directory”);    System out print(”Enter ur choice  : “);    BufferedReader br=new BufferedReader(new InputStreamReader(System in));       BufferedReader br1=new BufferedReader(new InputStreamReader(System in));       System out print(”Enter the source file name :”);       src=br1 readLine();       fin=new FileInputStream(src);       System out println(”Content in source file is : “);      catch(FileNotFoundException e)       System out println(”File not found”);       System out println(”Usage : To show a File “);        BufferedReader br1=new BufferedReader(new InputStreamReader(System in));        System out print(”Enter the source register name :”);        src=br1 readLine();        fin=new FileInputStream(src);       catch(FileNotFoundException e)        System out println(”Read file not open”);        BufferedReader br1=new BufferedReader(new InputStreamReader(System in));        System out create(”register the destination file name :”);        dest=br1 readLine();        fout=new FileOutputStream(dest);       catch(FileNotFoundException e)        System out println(”create verbally register not open”);       System out println(”Usage : copy from source register to destination file”);       System out println(”1 file copied”);       System out println(”File error”);      BufferedReader b=new BufferedReader(new InputStreamReader(System in));      System out print(”Enter the file name to delete :”);      String Filename=b readLine();      register f=new register(Filename);      if(f exists() && f isFile())       System out println(”1 file deleted”);       System out println(”File not found”);      System out println(”Invalid choice…”);

Forex Groups - Tips on Trading

Related article:
http://bloggeo.org/programs/2007/11/09/basic-operations-on-files/

comments | Add comment | Report as Spam


"Sample Question Paper with Solution" posted by ~Ray
Posted on 2007-12-15 15:05:38

Q1 a)label two types of java programs?Ans:Java is of dual utility. Applications and Applets. Applications: Standalone Java programs executed independently of a browser. The execution is done using the Java interpreter. Applets: Programs that are called through an HTML page and run on a Java-enabled browser. User’s PC downloads these Java bytecode from the Internet and run them on their own machines. To run an applet you need a java-enabled Web browser. Netscape Navigator is one of the java-enabled Web browsers b)Define dilate variable. furnish an example of the same. Ans :The object has state and behavior which is expressed by the variables and the methods. And the software objects are the real world objects which models a real world. It would have variables to indicate the current state and its behavior these variables are normally called as dilate variables. For example :A ball has specific characteristics such as diameter alter elasticity etc. We say these characteristics are necessary to the roll’s state of being. We also define a ball by what it does such it can be thrown or rolled or bounced. These activities are considered as the roll’s behavior. And the variables defining them ordain be the instance variables c)Differentiate between Binary search and the Linear search?Ans : Binary examine :1. Binary search searches for the given item in a sorted array 2. In this search reduces to half after every successive stage. Linear search :1. In linear search each element is compared with the given item to be searched for one by one. 2. In this method arrange should not be sorted one d) Assign the value of pie (i e. 3.142) to a variable with requisite data type. Ans : double pie=3.142;e)Explain with an example the if-else-if constructAns : While writing a java program in inspect you have to be your create based on many options then if-else-if statements are used. For eg. StatementIf con1adjust?YStatement 1If con2True?YStatement 2ifelse ifStatement 3elseStatement 4Part of the program for eg if(marks trueHi equals there -> falseHi equals HI -> falseThis will give error : cannot resolve symbol ,because EqualsIgnoreCase() is not right it should be equalsIgnoreCase()g) Evaluate the following expressions if the values are a=2 b=3 and c=9;Ans : 1) -22 2) 2divide BQ4 create verbally a method to act object of a class and label the above member method categorise salary{ double anntax=0; String name; String communicate; int phone; String sub_speci; double sal; double i_tax=0; public salary() { name=" "; communicate=" "; telecommunicate=0; sub_speci=" "; sal=0; anntax=0; } public salary(String nm,String Add,int ph,String sub,double sala) { name=nm; Address=Add; phone=ph; sub_speci=sub; sal=sala; } public void dispdet() { System out println("name "+label); System out println("Address "+Address); System out println("telecommunicate "+phone); System out println("subject specialisation "+sub_speci); System out println("salary "+sal); System out println("tax "+anntax); } public manifold taxcompute() { manifold t=sal*12; if(t>175000) anntax=sal*0.05; else anntax=0; go anntax; }} categorise dvd { public static void main() { salary teacher=new salary(); teacher taxcompute(); teacher dispdet(); }}Question 5create verbally a program to reason and display the sum of the following series categorise ser1{ public cancel main(int num) { double sum1=0,sum2=1,sum3=0; int i,j; for(i=1;i

Forex Groups - Tips on Trading

Related article:
http://chandanarora.blogspot.com/2007/11/sample-question-paper-with-solution.html

comments | Add comment | Report as Spam


"Java.net.??post" posted by ~Ray
Posted on 2007-12-09 13:39:06

import java io. BufferedReader;import java io. IOException;merchandise java io. InputStream;import java io. InputStreamReader;import java io. OutputStreamWriter;merchandise java io. UnsupportedEncodingException;merchandise java net. HttpURLConnection;import java net. MalformedURLException;import java net. URL;import java net. URLEncoder;merchandise java util. HashMap;import java util. Iterator;public class PostHander { StringstrCookie; Stringu; public voidpostHander(arrange url. HashMap map) { try { HashMap p =map; Iteratorentry = p entrySet() iterator(); Iterator key= p keySet() iterator(); URL url1 =new URL(url); HttpURLConnection connection = (HttpURLConnection) url1 openConnection(); connection setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); connection cerebrate(); if(connection getHeaderField("Set-Cookie") != null) { arrange s =connection getHeaderField("Set-Cookie"); if(s contains(";")) setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); HttpURLConnection huc = (HttpURLConnection)url1 openConnection(); huc setDoOutput(true); huc setRequestMethod("affix"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(60000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); huc setUseCaches(false); //huc setRequestProperty("Content-type". "text/html"); //huc setRequestProperty("Content-length",Integer toString(request length())); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); System out println(getStrCookie()); } OutputStreamWriter out = new OutputStreamWriter(huc getOutputStream(). "UTF-8"); boolean b =false; while(entry hasNext()) { if (b){ out write("&" +key next() toString() + "=" +URLEncoder convert(entry next() toString(). "UTF-8")); } else{ out write(key next() toString() + "=" +URLEncoder encode(entry next() toString(). "UTF-8")); b =true; } } out color(); out close(); huc cerebrate(); System out println(huc getResponseCode()); if(huc getResponseCode() != 200) go; InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); String str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } surprise(MalformedURLException e) { // TODOAuto-generated catch block System out println("url change error"); e printStackTrace(); } surprise(UnsupportedEncodingException e) { // TODOAuto-generated catch block System out println("EncodingException occurs"); e printStackTrace(); } catch(IOException e) { // TODOAuto-generated catch block System out println("error username or password,please checkit"); e printStackTrace(); } } public voidgetHander(String u) { try { URL url =new URL(u); HttpURLConnection huc = (HttpURLConnection)url openConnection(); huc setRequestMethod("GET"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(600000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); } InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); if(huc getHeaderField("Set-Cookie") != null) { arrange s =huc getHeaderField("Set-Cookie"); setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); String str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } catch(MalformedURLException e) { // TODOAuto-generated surprise block System out println("url change error"); e printStackTrace(); } surprise(UnsupportedEncodingException e) { // TODOAuto-generated catch block System out println("EncodingException occurs"); e printStackTrace(); } surprise(IOException e) { // TODOAuto-generated surprise block System out println("error username or password,gratify checkit"); e printStackTrace(); } } publicString getU() { if (this u== null) returnnull; returnu; } public voidsetU(String u) { this u =u; } publicString getStrCookie() { if(strCookie == null) returnnull; returnstrCookie; } public voidsetStrCookie(String strCookie) { this strCookie = strCookie; }}

Forex Groups - Tips on Trading

Related article:
http://blog.sina.com.cn/s/blog_4efc852f01000ckx.html

comments | Add comment | Report as Spam


"Java.net.??post" posted by ~Ray
Posted on 2007-12-09 13:39:06

merchandise java io. BufferedReader;import java io. IOException;merchandise java io. InputStream;merchandise java io. InputStreamReader;import java io. OutputStreamWriter;import java io. UnsupportedEncodingException;merchandise java net. HttpURLConnection;import java net. MalformedURLException;merchandise java net. URL;import java net. URLEncoder;import java util. HashMap;merchandise java util. Iterator;public class PostHander { StringstrCookie; Stringu; public voidpostHander(String url. HashMap map) { try { HashMap p =map; Iteratorentry = p entrySet() iterator(); Iterator key= p keySet() iterator(); URL url1 =new URL(url); HttpURLConnection connection = (HttpURLConnection) url1 openConnection(); connection setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); connection connect(); if(connection getHeaderField("Set-Cookie") != null) { String s =connection getHeaderField("Set-Cookie"); if(s contains(";")) setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); HttpURLConnection huc = (HttpURLConnection)url1 openConnection(); huc setDoOutput(true); huc setRequestMethod("POST"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(60000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); huc setUseCaches(false); //huc setRequestProperty("Content-type". "text/html"); //huc setRequestProperty("Content-length",Integer toString(request length())); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); System out println(getStrCookie()); } OutputStreamWriter out = new OutputStreamWriter(huc getOutputStream(). "UTF-8"); boolean b =false; while(entry hasNext()) { if (b){ out write("&" +key next() toString() + "=" +URLEncoder encode(entry next() toString(). "UTF-8")); } else{ out write(key next() toString() + "=" +URLEncoder encode(entry next() toString(). "UTF-8")); b =adjust; } } out flush(); out change state(); huc connect(); System out println(huc getResponseCode()); if(huc getResponseCode() != 200) return; InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); arrange str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } catch(MalformedURLException e) { // TODOAuto-generated surprise block System out println("url change error"); e printStackTrace(); } surprise(UnsupportedEncodingException e) { // TODOAuto-generated catch block System out println("EncodingException occurs"); e printStackTrace(); } catch(IOException e) { // TODOAuto-generated catch block System out println("error username or password,gratify checkit"); e printStackTrace(); } } public voidgetHander(String u) { try { URL url =new URL(u); HttpURLConnection huc = (HttpURLConnection)url openConnection(); huc setRequestMethod("GET"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(600000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); } InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); if(huc getHeaderField("Set-Cookie") != null) { arrange s =huc getHeaderField("Set-Cookie"); setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); String str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } catch(MalformedURLException e) { // TODOAuto-generated catch block System out println("url format error"); e printStackTrace(); } catch(UnsupportedEncodingException e) { // TODOAuto-generated surprise block System out println("EncodingException occurs"); e printStackTrace(); } catch(IOException e) { // TODOAuto-generated surprise block System out println("error username or password,gratify checkit"); e printStackTrace(); } } publicString getU() { if (this u== null) returnnull; returnu; } public voidsetU(arrange u) { this u =u; } publicString getStrCookie() { if(strCookie == null) returnnull; returnstrCookie; } public voidsetStrCookie(arrange strCookie) { this strCookie = strCookie; }}

Forex Groups - Tips on Trading

Related article:
http://blog.sina.com.cn/s/blog_4efc852f01000ckx.html

comments | Add comment | Report as Spam


"Java.net.??post" posted by ~Ray
Posted on 2007-12-09 13:39:06

import java io. BufferedReader;merchandise java io. IOException;merchandise java io. InputStream;merchandise java io. InputStreamReader;merchandise java io. OutputStreamWriter;import java io. UnsupportedEncodingException;merchandise java net. HttpURLConnection;merchandise java net. MalformedURLException;import java net. URL;import java net. URLEncoder;merchandise java util. HashMap;import java util. Iterator;public class PostHander { StringstrCookie; Stringu; public voidpostHander(String url. HashMap map) { try { HashMap p =map; Iteratorentry = p entrySet() iterator(); Iterator key= p keySet() iterator(); URL url1 =new URL(url); HttpURLConnection connection = (HttpURLConnection) url1 openConnection(); connection setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); connection connect(); if(connection getHeaderField("Set-Cookie") != null) { String s =connection getHeaderField("Set-Cookie"); if(s contains(";")) setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); HttpURLConnection huc = (HttpURLConnection)url1 openConnection(); huc setDoOutput(true); huc setRequestMethod("affix"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(60000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); huc setUseCaches(false); //huc setRequestProperty("Content-type". "text/html"); //huc setRequestProperty("Content-length",Integer toString(communicate length())); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); System out println(getStrCookie()); } OutputStreamWriter out = new OutputStreamWriter(huc getOutputStream(). "UTF-8"); boolean b =false; while(entry hasNext()) { if (b){ out write("&" +key next() toString() + "=" +URLEncoder encode(entry next() toString(). "UTF-8")); } else{ out write(key next() toString() + "=" +URLEncoder encode(entry next() toString(). "UTF-8")); b =adjust; } } out flush(); out change state(); huc connect(); System out println(huc getResponseCode()); if(huc getResponseCode() != 200) return; InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); arrange str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } catch(MalformedURLException e) { // TODOAuto-generated catch block System out println("url format error"); e printStackTrace(); } catch(UnsupportedEncodingException e) { // TODOAuto-generated catch block System out println("EncodingException occurs"); e printStackTrace(); } catch(IOException e) { // TODOAuto-generated catch block System out println("error username or password,gratify checkit"); e printStackTrace(); } } public voidgetHander(String u) { try { URL url =new URL(u); HttpURLConnection huc = (HttpURLConnection)url openConnection(); huc setRequestMethod("GET"); huc setRequestProperty( "User-Agent". "Mozilla/4.0(compatible; MSIE 6.0; Windows NT 5.1; . NET CLR 1.0.3215; . NET CLR1.0.3705)"); huc setConnectTimeout(600000); huc setRequestProperty("Cache-Control". "no-cache"); huc setRequestProperty("Connection". "Keep-Alive"); if(this getStrCookie() != null) { huc setRequestProperty("Cookie" getStrCookie()); } InputStreamin = huc getInputStream(); System out println(huc getHeaderFields()); if(huc getHeaderField("Set-Cookie") != null) { arrange s =huc getHeaderField("Set-Cookie"); setStrCookie(s substring(0 s indexOf(";"))); } System out println(getStrCookie()); BufferedReader reader = new BufferedReader(newInputStreamReader( in,"gbk")); String str =reader readLine(); while (str!= null) { System out println(str); str =reader readLine(); } } catch(MalformedURLException e) { // TODOAuto-generated surprise block System out println("url format error"); e printStackTrace(); } surprise(UnsupportedEncodingException e) { // TODOAuto-generated catch block System out println("EncodingException occurs"); e printStackTrace(); } surprise(IOException e) { // TODOAuto-generated catch block System out println("error username or password,please checkit"); e printStackTrace(); } } publicString getU() { if (this u== null) returnnull; returnu; } public voidsetU(arrange u) { this u =u; } publicString getStrCookie() { if(strCookie == null) returnnull; returnstrCookie; } public voidsetStrCookie(String strCookie) { this strCookie = strCookie; }}

Forex Groups - Tips on Trading

Related article:
http://blog.sina.com.cn/s/blog_4efc852f01000ckx.html

comments | Add comment | Report as Spam


"BufferedReader question" posted by ~Ray
Posted on 2007-11-27 20:03:39

This question is not answered. Helpful answers available: 2. change by reversal answers available: 1. hi everyonei undergo a bufferedreader related question.. i wrote a code that is supposed to construe from a text file words separated by lay and show them.. the code works fine but the first character in the file is not read.. e g let's say that my text contains the following words: "bob eve pass summer"my program reads "ob eve winter pass" so there is the "b" missing.. why is that happening ????this is the method responsible for reading: "schedule ordain now exit..." reads a engrave from the file and then does nothing with it object test for eof. Just construe lines in an infinite circle until the lie construe is null then end out of the loop. I believe that the "reader read()" in the while statement is reading the first character of each lie through the BufferedReader leaving the rest of the lie for the readLine() function. If you readLine() every time you get to the while loop you can get rid of this problem. Unless otherwise licensed code in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5233408

comments | Add comment | Report as Spam


"How to use BufferedReader?" posted by ~Ray
Posted on 2007-11-17 15:35:07

You are currently viewing our boards as a guest which gives you limited access to view most discussions and find our other features. By joining our free community you will: undergo the possibility to acquire one of our surprises if you are an active member find many other special features that will be introduced later. Registration is abstain simple and absolutely free so please. ! If you have any problems with the registration affect or your account login please. How do I use BufferedReader to read whole paragraph? I dont experience how to go away it except typing: class Reader throws IO Exception{ BufferedReader reader - new BufferedReader();}I know Im supposed to use readline() but I just dont know how to put it...... BTW can Bufferedreader read strings inside a vector? File file = new File(filePath);try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(file))); arrange line; while((line = br readLine()) != null) System out println(lie); br change state();} surprise(IOException e) { ...}Vector<String> v = new Vector<arrange>();for(int j = 0; j < 5; j++) { v add(arrange valueOf(j));}// acquire the third elementString s = v get(2);

Forex Groups - Tips on Trading

Related article:
http://www.java-forums.org/new-java/3524-how-use-bufferedreader.html

comments | Add comment | Report as Spam


"Reading with BufferedReader" posted by ~Ray
Posted on 2007-11-09 17:19:04

Note: Regular member posting and registration is currently DISABLED as we move the forums to a new server. When this communicate disappears it means you're on the new server and can post again. Thanks for the patience. I was reading about the BufferedReader categorise and looked at its construe methods. I noticed it overrides one of the two (non-abstract) read methods read(burn[] cbuf int off int len) but not read(char[] cbuf). Because it does not override construe(char[] cbuf) it makes me wonder if for reading an entire register into a burn[] array more efficient than using read(burn[] cbuf int off int len). Which is exceed?Or better yet is there a better way of doing this: //try catch finally excluded for simplicityFile f = new register("abc def");burn[] cbuf = new burn[(int)f length()]; //assuming the file is small enoughBufferedReader br = new BufferedReader(new FileReader(f));br read(cbuf);//or br read(cbuf. 0. (int)f length()); ???br change state(); That's really not what BufferedReader is for. As the label implies it's designed to simplify the process of reading a small amount of data (usually a lie) into a buffer for processing. Using it for reading the whole file into a burn[] is at beat superfluous and at worst detrimental to performance -- I would suspect that the overwritten read() exists to back up act track of the modify and make sure that read()s don't hinder with the internal modify more than they ought. Either way it ordain almost certainly store more data than is necessary for such an operation. Questions by PM may be ignored. If you have a DHTML challenge please affix in the forum.

Forex Groups - Tips on Trading

Related article:
http://www.dynamicdrive.com/forums/showthread.php?t=24651

comments | Add comment | Report as Spam


"BufferedReader" posted by ~Ray
Posted on 2007-11-03 13:50:48

Hello!I have the following problem: I did a answer where I open a file and search for certain strings andthe result is saved in one String named text. (it is a huge amount of text btw,)What I want to do is to construe this special arrange in another answer (if that is possible) and changethe formating of it. Here is the method I used for the dress of format: Now. I don't want to actually read a register like in the function above. I be to construe and dress the prove arrange of another method which returns void. How do I change THIS method so it can use the Stringof the other one? Can the BufferedReader be also used in the way I be to have it or can it only be usedfor reading files?I hope that you can help me and/or give some useful advice to me... Thank you. the result is saved in one String named text. (it isa huge be of text btw,)What I be to do is to construe this special arrange inanother answer (if that is possible) They are called methods in Java I be to read and change the result String of another method which returns void. How do I change THIS method so it can use the Stringof the other one? I fit's important that the "other" method return cancel you could possibly use a StringBuffer and append / replace / insert the characters as needed. Can the BufferedReader be also usedin the way I be to have it or can it only be usedfor reading files? No idea frankly. Someone else ordain surely know. Darryl srry. I didn't know. I'll use the expression "method" from now on ahm. firstly the other method has to be void.. come up. I don't really undergo to use two methods. I can combine those two in one.. it's just that I be to use the String named text again because it has to be appended on a textarea er. how to put this.. because the arrange has a lot of text in it I be it to somehow be read and actually go through come up every line like it would do when you open a file and tell him to "line = br readLine() != null" though I don't know again how to do this with this method posted above somehow.. but. how?and no. I don't think that you are missing the point. CeciNEstPasUnProgrammeur... And maybe I just don't experience the purpose of go come up enough. As I don't undergo the same knowledge of java not change surface the basics as you surely have I need a few guidelines and that's why I'm asking... Unless otherwise licensed label in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5208399

comments | Add comment | Report as Spam


"BufferedReader" posted by ~Ray
Posted on 2007-11-03 13:50:43

Hello!I have the following problem: I did a answer where I change state a file and examine for certain strings andthe result is saved in one String named text. (it is a huge amount of text btw,)What I want to do is to read this special arrange in another function (if that is possible) and changethe formating of it. Here is the method I used for the dress of format: Now. I don't want to actually read a file desire in the answer above. I want to read and change the prove arrange of another method which returns cancel. How do I change THIS method so it can use the Stringof the other one? Can the BufferedReader be also used in the way I want to have it or can it only be usedfor reading files?I hope that you can back up me and/or give some useful advice to me... Thank you. the prove is saved in one arrange named text. (it isa huge be of text btw,)What I be to do is to construe this special String inanother answer (if that is possible) They are called methods in Java I be to construe and dress the result arrange of another method which returns void. How do I dress THIS method so it can use the Stringof the other one? I fit's important that the "other" method go cancel you could possibly use a StringBuffer and attach / regenerate / insert the characters as needed. Can the BufferedReader be also usedin the way I want to have it or can it only be usedfor reading files? No idea frankly. Someone else ordain surely experience. Darryl srry. I didn't know. I'll use the expression "method" from now on ahm. firstly the other method has to be void.. well. I don't really have to use two methods. I can combine those two in one.. it's just that I want to use the String named text again because it has to be appended on a textarea er. how to put this.. because the arrange has a lot of text in it I be it to somehow be read and actually go through well every lie desire it would do when you open a register and tell him to "lie = br readLine() != null" though I don't experience again how to do this with this method posted above somehow.. but. how?and no. I don't think that you are missing the inform. CeciNEstPasUnProgrammeur... And maybe I just don't experience the intend of go well enough. As I don't have the same knowledge of java not even the basics as you surely have I be a few guidelines and that's why I'm asking... Unless otherwise licensed label in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5208399

comments | Add comment | Report as Spam


"How to exit thread that uses BufferedReader.readline()" posted by ~Ray
Posted on 2007-10-28 11:48:29

Hi Folks,I undergo the following label that starts a thread to construe from a BufferredReader. Here it calls BufferredReader. readLine() to read lines from buffer and waits until it finds something. There is another go that is feeding into this modify from the create of Runtime exec() method. My problem is the go once started never stops until the JVM exits or Runtime exec() is called again to run another process. Is there some way to move this thread without calling Runtime exec() again?Below is the code:private void startThreadToReadFrmmodify (final BufferedReader br final String prependLine) {Thread errOutputPrinter = new Thread () {public void run () {arrange line;try {while ((lie = br readLine()) != null) {System out println(prependLine + "> " + lie);}} surprise (IOException e) {e printStackTrace();} }};errOutputPrinter start();} I meant there is an InputStreamReader that this buffer reads from. The code is as below:String commandToExecute = "<some group file>";Process sqlPrcs = Runtime getRuntime() exec(commandToExecute);InputStream es = sqlPrcs getErrorStream();InputStreamReader esr = new InputStreamReader(es); BufferedReader ber = new BufferedReader(esr); startThreadToReadFrmmodify(ber. "Error by " + processName);Thanks,Sandeep I dont' know if this is your problem but If the program you execute fails to return any output the process will hang when trying to construe the results. I got around this issue by dynamically writing my execution statement in a /tmp/compose register with execution permissions. The last thing I had in the compose was emit "end". When the stuff I wanted to execute failed to produce output I would catch the end and the input stream would change state.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5208031

comments | Add comment | Report as Spam


"How to exit thread that uses BufferedReader.readline()" posted by ~Ray
Posted on 2007-10-28 11:48:29

Hi Folks,I have the following code that starts a thread to read from a BufferredReader. Here it calls BufferredReader. readLine() to read lines from buffer and waits until it finds something. There is another thread that is feeding into this modify from the output of Runtime exec() method. My problem is the thread once started never stops until the JVM exits or Runtime exec() is called again to run another affect. Is there some way to exit this go without calling Runtime exec() again?Below is the code:private cancel startThreadToReadFrmBuffer (final BufferedReader br final arrange prependLine) {Thread errOutputPrinter = new go () {public cancel run () {String line;try {while ((lie = br readLine()) != null) {System out println(prependLine + "> " + lie);}} surprise (IOException e) {e printStackTrace();} }};errOutputPrinter start();} I meant there is an InputStreamReader that this modify reads from. The code is as below:String commandToExecute = "<some batch register>";Process sqlPrcs = Runtime getRuntime() exec(commandToExecute);InputStream es = sqlPrcs getErrorStream();InputStreamReader esr = new InputStreamReader(es); BufferedReader ber = new BufferedReader(esr); startThreadToReadFrmBuffer(ber. "Error by " + processName);Thanks,Sandeep I dont' experience if this is your problem but If the schedule you execute fails to return any output the process will fasten when trying to construe the results. I got around this air by dynamically writing my execution statement in a /tmp/script file with execution permissions. The last thing I had in the compose was emit "end". When the stuff I wanted to execute failed to create create I would surprise the end and the enter stream would change state.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5208031

comments | Add comment | Report as Spam


"Create a user menu in console mode" posted by ~Ray
Posted on 2007-10-23 15:45:28

You are currently viewing our boards as a guest which gives you limited access to believe most discussions and access our other features. By joining our free community you ordain: find many other special features that will be introduced later. Registration is abstain simple and absolutely remove so gratify. ! If you have any problems with the registration process or your account login gratify. The Java Application observe (JAMon) is a remove simple high performance go safe. Java API that allows developers to easily observe production applications. JAMon can be used to cause application performance bottlenecks user/application interactions and application scalability. JAMon gathers summary statistics such as hits execution times (total average minimum maximum standard deviation) and simultaneous application requests. JAMon statistics are displayed in the sortable JAMon report. ChangesThis channel adds the ability to monitor Tomcat 4/5/5.5/6. JBoss 4.0.5 and Jetty 6.1.5 summon resources. It adds an EJB3 interceptor that ordain monitor EJB calls and exceptions. Added to existing features these allow developers to monitor servlets/JSPs. EJBs. JDBC/SQL and log4j without requiring any code changes on their part. URL:

Forex Groups - Tips on Trading

Related article:
http://www.java-forums.org/new-java/3189-create-user-menu-console-mode.html

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the bufferedreader archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


bufferedreader