Jump to content

Formatar String com Link (Substituir Espaços por +)


HilarYo
 Share

Go to solution Solved by alexandre1985,

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.