新作业:json解析以及excel生成

先随便push点什么东西上去吧
main
lensfrex 2 years ago
parent 4cd5d5fc23
commit c71830fd87
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 2
      .idea/compiler.xml
  2. 13
      .idea/libraries/Maven__com_google_code_gson_gson_2_8_6.xml
  3. 1
      .idea/misc.xml
  4. 1
      .idea/modules.xml
  5. 17
      DoubanDataPraserS/DoubanDataPraserS.iml
  6. 44
      DoubanDataPraserS/pom.xml
  7. 7
      DoubanDataPraserS/src/main/java/me/lensfrex/doubandps/Main.java
  8. 20
      DoubanDataPraserS/src/main/java/me/lensfrex/doubandps/MovieInformation.java
  9. 49
      DoubanDataPraserS/src/main/java/me/lensfrex/doubandps/utils/IOUtil.java
  10. 1752
      DoubanDataPraserS/src/main/resources/douban.json

@ -8,9 +8,11 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="vegetables" />
<module name="DoubanDataPraserS" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="DoubanDataPraserS" target="8" />
<module name="vegetables" target="8" />
</bytecodeTargetLevel>
</component>

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.google.code.gson:gson:2.8.6">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.6/gson-2.8.6-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.6/gson-2.8.6-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -4,6 +4,7 @@
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/vegetables/pom.xml" />
<option value="$PROJECT_DIR$/DoubanDataPraserS/pom.xml" />
</list>
</option>
</component>

@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/AmberGround.iml" filepath="$PROJECT_DIR$/AmberGround.iml" />
<module fileurl="file://$PROJECT_DIR$/DoubanDataPraserS/DoubanDataPraserS.iml" filepath="$PROJECT_DIR$/DoubanDataPraserS/DoubanDataPraserS.iml" />
<module fileurl="file://$PROJECT_DIR$/vegetables/vegetables.iml" filepath="$PROJECT_DIR$/vegetables/vegetables.iml" />
</modules>
</component>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
</component>
</module>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.lensfrex</groupId>
<artifactId>DoubanDataPraserS</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,7 @@
package me.lensfrex.doubandps;
public class Main {
public static void main(String[] args) {
}
}

@ -0,0 +1,20 @@
package me.lensfrex.doubandps;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
@Data
public class MovieInformation {
@SerializedName("name_Ch")
private String chineseName;
@SerializedName("name_Fr")
private String frenchName;
@SerializedName("num")
private int id;
private float point;
private int year;
}

@ -0,0 +1,49 @@
package me.lensfrex.doubandps.utils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.Charset;
public class IOUtil {
public static String inputStreamToString(InputStream inputStream, Charset charSet) {
byte[] bytes = readDataFromInputStream(inputStream);
if (bytes != null) {
return new String(bytes, charSet);
} else {
return null;
}
}
public static byte[] readDataFromInputStream(InputStream inputStream) {
return readDataFromInputStream(inputStream, 5);// read every 5kb in default
}
public static byte[] readDataFromInputStream(InputStream inputStream, int byteAllocation) {
try {
ByteArrayOutputStream byteArrayInputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024 * byteAllocation];
for (int length; (length = inputStream.read(bytes)) != -1; ) {
byteArrayInputStream.write(bytes, 0, length);
}
byteArrayInputStream.flush();
inputStream.close();
byteArrayInputStream.close();
return byteArrayInputStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void writeFile(byte[] bytes, File file) throws Exception {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(bytes);
fileOutputStream.close();
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save