티스토리 뷰
필요한 경우
- oauth 인증시 redirect uri
- query 파라미터로 /등 특수문자를 보낼 때
사용불가 캐릭터
- / (forward slash)
- ? (question mark)
- & (ampersand)
- = (equals sign)
- % (percent sign)
- + (plus sign)
- # (hash or pound sign)
- < (less than sign)
- > (greater than sign)
- : (colon)
- , (comma)
Sample Code
URL Encode
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class UrlEncoderExample {
public static void main(String[] args) throws UnsupportedEncodingException {
String originalString = "urlcodode this string "https://www.tistory.com/redirect";
String encodedString = URLEncoder.encode(originalString, "UTF-8");
System.out.println("Original string: " + originalString);
// https://www.tistory.com/redirect
System.out.println("URL-encoded string: " + encodedString);
// https%3A%2F%2Fwww.tistory.com%2Fredirect
}
}
URL Decode
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
public class UrlDecoderExample {
public static void main(String[] args) throws UnsupportedEncodingException {
String encodedString = "https%3A%2F%2Fwww.tistory.com%2Fredirect";
String decodedString = URLDecoder.decode(encodedString, "UTF-8");
System.out.println("URL-encoded string: " + encodedString);
// https%3A%2F%2Fwww.tistory.com%2Fredirect
System.out.println("URL-decoded string: " + decodedString);
// https://www.tistory.com/redirect
}
}
'Tech' 카테고리의 다른 글
RubyOnRails 인덱스 추가하기 (0) | 2023.04.24 |
---|---|
Golang - Base64(Encoding, Decoding) Sample Code (0) | 2023.02.14 |
Java - Base64(Encoding, Decoding) Sample Code (0) | 2018.10.02 |
Scala - Hello World + Gradle Setting (0) | 2018.10.02 |
Kotlin - Hello World + Gradle Setting (0) | 2018.10.02 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- URLEncode
- ActiveRecord
- golang
- Source
- index
- error
- version
- enum
- RubyOnRails
- sample
- Mac
- git
- BASE64
- ChatGPT
- Scala
- 노가다
- HelloWorld
- Knowhow
- gradle
- vscode
- 사용법
- Algorithm
- JQuery
- js
- cdn
- Snippet
- Regex
- urldecode
- spring
- Kotlin
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함