current location:Home > Technical Articles > Java > JavaBase

  • How to determine whether a file exists in java and create a new file if it does not exist
    How to determine whether a file exists in java and create a new file if it does not exist
    In "java", the method to determine whether a file exists or create a new file if it does not exist is: first save the file path to a file object, and then use the "exists()" method to determine whether the file exists. If it does not exist, use "createNewFile() )" method to create a new file.
    JavaBase 6122 2019-11-25 10:10:55
  • Summary of file downloading and garbled file names in Java
    Summary of file downloading and garbled file names in Java
    Garbled java download file names can be solved by setting the file name encoding when downloading. In IE browser, you can use the encode() method to specify the encoding format. Files in Java can be downloaded in the form of streams, and files can be read using the FileInputStream method.
    JavaBase 3490 2019-11-25 10:08:28
  • The difference between expressions i++ and ++i in java
    The difference between expressions i++ and ++i in java
    The difference between the expressions "i++" and "++i" in "java" is: "i++" means assigning a value first and then incrementing; "++i" means incrementing first and then assigning a value. For example: "j=i++" means that the variable "i" is first assigned to the variable "j" and then increments; "j=++i" means that the variable "i" is first incremented and then the variable is assigned a value.
    JavaBase 3452 2019-11-25 09:59:38
  • Reasons and solutions for garbled Chinese characters in Java
    Reasons and solutions for garbled Chinese characters in Java
    Java Chinese characters are garbled because the default encoding method in Java is different from the Chinese character encoding method. We only need to convert the encoding format when outputting Chinese characters and reading Chinese characters from parameters. You can use String(str.getBytes("Encoding" ),"encoding"); statement changes the encoding format.
    JavaBase 7731 2019-11-25 09:42:36
  • Garbled characters appear when sending emails via java mail
    Garbled characters appear when sending emails via java mail
    The solution to garbled characters when sending emails using the "mail" package in "java" is: first, specify the text encoding as "GB2312" when sending the body text, then specify the title encoding as "GB2312" when setting the email title, and finally send the body text. Just specify the transfer encoding as "base64" encoding.
    JavaBase 2960 2019-11-25 09:27:05
  • How to enter an array from the keyboard in java
    How to enter an array from the keyboard in java
    The "java" method of inputting an array from the keyboard is: first create an object through the "Scanner" class, then call the "next()" method through this object to obtain the input data, and return the input data by calling the "toString()" method The object value represented, and finally the data is added to the array through a loop.
    JavaBase 14454 2019-11-23 16:00:50
  • Java implements uploading pictures to the server
    Java implements uploading pictures to the server
    The method of "java" to upload images to the server is: first set the buffer size and temporary file directory, and set the size limit of the uploaded file, then parse the request object to obtain the "List" object of the uploaded content, and determine whether it is an uploaded file. Then call the "write()" method to write the uploaded content to the file.
    JavaBase 2997 2019-11-23 15:40:23
  • The file name is garbled when java downloads the file
    The file name is garbled when java downloads the file
    When "java" downloads files, the file name appears garbled. If it is a file name encoding problem, you can encode the file name to "UTF-8" or "ISO". If it is a browser incompatibility problem, you can use "URLEncode" to encode the file name. Encode "UTF-8" or convert bytes to "ISO".
    JavaBase 3687 2019-11-23 15:04:52
  • How to verify whether the image verification code is correct in JAVA
    How to verify whether the image verification code is correct in JAVA
    The method of verifying the image verification code in "java" is: first, you need to obtain the verification code object entered by the user, and then first determine whether the verification code is empty. If it is not empty, obtain the "toString()" method represented by the verification code. Number" object value, and finally compare the verification code object value with the specified object to determine whether it is correct.
    JavaBase 2881 2019-11-23 14:47:31
  • Garbled characters appear when running java projects through bash/cmd
    Garbled characters appear when running java projects through bash/cmd
    The reason why garbled characters appear when running the "java" project through "bash" or "cmd" is: the default encoding of "cmd" and "bash" is "GBK". The solution is: first set the encoding method of "cmd" to "utf-8" through the "chcp 65001" command, and then specify the encoding parameters when running the project.
    JavaBase 3707 2019-11-23 13:56:30
  • How to save files locally in java
    How to save files locally in java
    The method to save files locally in "java" is: first create a file object according to the file path to be saved, and then use the "exists" method to determine whether the file exists. If it does not exist, create a new file. If it exists, start passing the "FileOutPutStream" ” class creates a new file and writes data to the file.
    JavaBase 11845 2019-11-23 13:28:02
  • What are the methods to enter a character in java
    What are the methods to enter a character in java
    The methods for inputting a character from the keyboard in "java" are: 1. Use the "read()" method to obtain, but this method can only obtain one character, and the type of the variable obtained must be of the "char" type; 2. , Use the "BufferedReader" class to obtain; 3. Use the "Scanner" class to obtain.
    JavaBase 6136 2019-11-23 11:48:52
  • How to calculate the day of the year for a specified date in java
    How to calculate the day of the year for a specified date in java
    How to calculate the day of the year for a specified date in Java: first calculate whether it is a leap year or an ordinary year through the year, February 28 days in ordinary years, February 29 days in leap years, the number of days in the remaining months is fixed, and then the number of days in the month before the specified month and The days in the specified months are added together, and the sum is the day of the year.
    JavaBase 4221 2019-12-05 11:57:06
  • Strings in java are always garbled
    Strings in java are always garbled
    The reason why strings in "java" are always garbled is: "TOMCAT" uses "ISO8859-1" encoding by default. The solution is: first use "ISO8859-1" to convert the string obtained from "TOMCAT" into a byte array, and then use "GBK" to encode it.
    JavaBase 3452 2019-11-23 11:25:32
  • How to determine whether a character is a number in java
    How to determine whether a character is a number in java
    The method to determine whether a character is a number in "java" is: you can use the static method "isDigit()" in the "Character" class. The "isDigit()" method is used to determine whether the parameter character passed in is a number. If If the parameter character is a number, "true" is returned, otherwise "false" is returned.
    JavaBase 3132 2019-11-23 11:15:51

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28