HilarYo Posted April 5, 2015 at 09:40 PM Report Share #580831 Posted April 5, 2015 at 09:40 PM Boas, eu tenho seguinte código: public static void main(String[] args) throws Exception { URL ipg = new URL("https://www.exemplo.com/search?text=conteudo+a+pesquisar"); BufferedReader in =new BufferedReader(new InputStreamReader(ipg.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } Eu tenho criei um java frame form com um TextField, que deverá fazer o seguinte: Pegar no texto substituir os espaços por + e adicionar ao url Por exemplo escreviamos no TextField conteudo a pesquisar, e formava o seguinte link: URL ipg = new URL("https://www.exemplo.com/search?text=conteudo+a+pesquisar"); Alguém me pode ajudar? Obrigado, Cumps Link to comment Share on other sites More sharing options...
Solution alexandre1985 Posted April 6, 2015 at 02:51 PM Solution Report Share #580848 Posted April 6, 2015 at 02:51 PM Tens de fazer um getText() ao TextField e guardar numa string. Depois tens de arranjar uma maneira de transformar espaços em branco em "+". Uma maneira de fazeres a substituição pode ser assim: String my_new_str = my_str.replaceAll(" ", "+"); http://alexandre1985.github.io Link to comment Share on other sites More sharing options...
HilarYo Posted April 7, 2015 at 05:39 PM Author Report Share #580892 Posted April 7, 2015 at 05:39 PM Obrigado, Resultou 😄 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now