Editing
Character encoding
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= checks = Java biedt de mogelijkheid om de correcte character encoding van bestanden vast te stellen. Onder staan enkele voorbeelden. == check 1 == So if I compile this, we can check. <pre> public class CharSetTest { public static void main(String[] args) { System.out.println("Default Charset=" + Charset.defaultCharset()); System.setProperty("file.encoding", "Latin-1"); System.out.println("file.encoding=" + System.getProperty("file.encoding")); System.out.println("Default Charset=" + Charset.defaultCharset()); System.out.println("Default Charset in Use=" + getDefaultCharSet()); } private static String getDefaultCharSet() { OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream()); String enc = writer.getEncoding(); return enc; } } </pre> == check 2 == <pre> try this simple program import java.io.FileWriter; import java.io.IOException; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); } } </pre> == check 3 == <pre> import java.io.FileWriter; import java.io.IOException; import java.util.Locale; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); Locale locale = Locale.getDefault(); System.out.println(locale); } } </pre> == check 4 == <pre> this is the program that I run on test import java.io.BufferedWriter; import java.io.FileWriter; public class FileWrite { public static void main(String args[]) { try { // Create file FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write("Damásio Pinto Do Carmo"); // Close the output stream out.close(); } catch (Exception e) {// Catch exception if any System.err.println("Error: " + e.getMessage()); } } } </pre> <hr> Terug naar: [[Webhuis Infrastructuur]]
Summary:
Please note that all contributions to Webhuis wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Voorpagina
Cobol and PostgreSQL
PostgreSQL
CFEngine
Proxmox
Webhuis Kennisbank
Basale infra
Webhuis bouwstenen
Webhuis configuratie
Webhuis Infra
Webhuis Support
Webhuis Raspberry
Opzet Applicaties
Business Applicaties
Community portal
Current events
Recent changes
Random page
Help
sitesupport
Tools
What links here
Related changes
Special pages
Page information