赞
踩
public void test03() {
Word07Writer writer = new Word07Writer();
String str = "{\"font_size\":0.4,\"font_color\":\"#FFFFFF\",\"background_alpha\":0.5,\"background_color\":\"#9C27B0\",\"Stroke\":\"none\",\"body\":[{\"from\":0.76,\"to\":1.78,\"location\":2,\"content\":\"Phil: Welcome to the first unit!\"},{\"from\":1.78,\"to\":4.58,\"location\":2,\"content\":\"This is the unit where you get the “big\\npicture,” and a first few details.\"},{\"from\":4.58,\"to\":9.06,\"location\":2,\"content\":\"Nick :You’re going to learn the basics of\\nhow the Internet works.\"},{\"from\":9.06,\"to\":13.29,\"location\":2,\"content\":\"You might even figure out which one of us\\nis Phil and which one is Nick.\"},{\"from\":13.29,\"to\":17.32,\"location\":2,\"content\":\"We hope to help you to understand *why* the\\nInternet is designed the way it is.\"},{\"from\":17.32,\"to\":19.18,\"location\":2,\"content\":\"What are some of its strengths and weaknesses?\"},{\"from\":19.18,\"to\":23.68,\"location\":2,\"content\":\"We’ll also teach you some of the commonly\\naccepted network design principles, such as\"},{\"from\":23.68,\"to\":26.49,\"location\":2,\"content\":\"layering, encapsulation, and packet switching.\"},{\"from\":26.49,\"to\":29.72,\"location\":2,\"content\":\"At the end of this unit, you should be able\\nto answer questions such as “What is the\"},{\"from\":29.72,\"to\":30.72,\"location\":2,\"content\":\"Internet?\"},{\"from\":30.72,\"to\":35.13,\"location\":2,\"content\":\"What is an Internet Address?” and “How\\ndo applications such as the web, Skype, and\"},{\"from\":35.13,\"to\":36.34,\"location\":2,\"content\":\"BitTorrent work?”\"},{\"from\":36.34,\"to\":39.73,\"location\":2,\"content\":\"These principles will help you design better\\nnetworks in the future.\"},{\"from\":39.73,\"to\":43.62,\"location\":2,\"content\":\"Phil: At the end of the first unit, you should\\nbe familiar with something called the “4-layer\"},{\"from\":43.62,\"to\":45.75,\"location\":2,\"content\":\"model” of the Internet.\"},{\"from\":45.75,\"to\":49.49,\"location\":2,\"content\":\"It describes how the Internet is broken down\\ninto four distinct layers.\"},{\"from\":49.49,\"to\":54.13,\"location\":2,\"content\":\"You’ll learn what layers are and why they’re\\na basic principle of good network design.\"},{\"from\":54.13,\"to\":57.44,\"location\":2,\"content\":\"You’ll learn what the Internet’s four\\nlayers are and how they work together.\"},{\"from\":57.44,\"to\":61.64,\"location\":2,\"content\":\"You’ll learn that most applications use\\na transport layer called the Transmission\"},{\"from\":61.64,\"to\":66.22,\"location\":2,\"content\":\"Control Protocol, or TCP, and how some applications\\nuse it.\"},{\"from\":66.22,\"to\":70.63,\"location\":2,\"content\":\"You’ll also learn that the Internet works\\nby breaking data up into small units called\"},{\"from\":70.63,\"to\":71.63,\"location\":2,\"content\":\"packets.\"},{\"from\":71.63,\"to\":75.17,\"location\":2,\"content\":\"For example, when you request a web page,\\nyour computer sends some packets to the web\"},{\"from\":75.17,\"to\":76.17,\"location\":2,\"content\":\"server.\"},{\"from\":76.17,\"to\":80.32,\"location\":2,\"content\":\"The Internet decides how these packets of\\ndata arrive to the right destination.\"},{\"from\":80.32,\"to\":86.13,\"location\":2,\"content\":\"Nick: This unit also examines one layer, called\\nthe network layer, in a bit of detail.\"},{\"from\":86.13,\"to\":88.45,\"location\":2,\"content\":\"You might have heard of IP, the Internet Protocol.\"},{\"from\":88.45,\"to\":92.7,\"location\":2,\"content\":\"It’s the protocol named after the Internet\\nbecause it’s the glue that lets the whole\"},{\"from\":92.7,\"to\":93.98,\"location\":2,\"content\":\"thing work.\"},{\"from\":93.98,\"to\":98.54,\"location\":2,\"content\":\"You can change all of the other layers, but\\nto be using the Internet you need to be using\"},{\"from\":98.54,\"to\":101.51,\"location\":2,\"content\":\"the Internet Protocol at the network layer.\"},{\"from\":101.51,\"to\":105.28,\"location\":2,\"content\":\"You’ll learn about what the Internet Protocol\\ndoes and how it does it.\"},{\"from\":105.28,\"to\":108.83,\"location\":2,\"content\":\"You’ll learn about Internet Protocol addresses\\nand how they’re assigned.\"},{\"from\":108.83,\"to\":113.44,\"location\":2,\"content\":\"You’ll start to learn how the Internet decides\\nthe path a packet should take based on Internet\"},{\"from\":113.44,\"to\":114.44,\"location\":2,\"content\":\"addresses.\"},{\"from\":114.44,\"to\":119.33,\"location\":2,\"content\":\"Phil: Finally, we’ll show you a few software\\ntools you can use to inspect how your computer\"},{\"from\":119.33,\"to\":120.33,\"location\":2,\"content\":\"is using the Internet.\"},{\"from\":120.33,\"to\":123.92,\"location\":2,\"content\":\"So you can apply what you’ve learned in\\nthis unit to the next time you browse the\"},{\"from\":123.92,\"to\":123.98,\"location\":2,\"content\":\"web!\"}]}";
String strChinese = "{\"font_size\":0.4,\"font_color\":\"#FFFFFF\",\"background_alpha\":0.5,\"background_color\":\"#9C27B0\",\"Stroke\":\"none\",\"body\":[{\"from\":0.76,\"to\":1.78,\"location\":2,\"content\":\"菲尔:欢迎来到第一单元! \"},{\"from\":1.78,\"to\":4.58,\"location\":2,\"content\":\"这是您获得“全局”和头几个细节的单元。 \"},{\"from\":4.58,\"to\":9.06,\"location\":2,\"content\":\"尼克:您将学习互联网的基本原理。 \"},{\"from\":9.06,\"to\":13.29,\"location\":2,\"content\":\"您甚至可以弄清楚我们中的哪一位是Phil,而哪一位是Nick。 \"},{\"from\":13.29,\"to\":17.32,\"location\":2,\"content\":\"我们希望能帮助您了解互联网的设计原因。 \"},{\"from\":17.32,\"to\":19.18,\"location\":2,\"content\":\"它的优点和缺点是什么? \"},{\"from\":19.18,\"to\":23.68,\"location\":2,\"content\":\"我们还将教您一些普遍接受的网络设计原则,例如\"},{\"from\":23.68,\"to\":26.49,\"location\":2,\"content\":\"分层,封装和数据包交换。 \"},{\"from\":26.49,\"to\":29.72,\"location\":2,\"content\":\"在本单元的最后,您应该能够回答诸如“什么是\"},{\"from\":29.72,\"to\":30.72,\"location\":2,\"content\":\"互联网? \"},{\"from\":30.72,\"to\":35.13,\"location\":2,\"content\":\"什么是互联网地址?”和“如何处理网络,Skype和\"},{\"from\":35.13,\"to\":36.34,\"location\":2,\"content\":\" BitTorrent的工作?” \"},{\"from\":36.34,\"to\":39.73,\"location\":2,\"content\":\"这些原则将帮助您将来设计更好的网络。 \"},{\"from\":39.73,\"to\":43.62,\"location\":2,\"content\":\" Phil:在第一个单元的结尾,您应该熟悉称为“ 4层”的内容\"},{\"from\":43.62,\"to\":45.75,\"location\":2,\"content\":\"互联网”。 \"},{\"from\":45.75,\"to\":49.49,\"location\":2,\"content\":\"它描述了如何将Internet分为四个不同的层。 \"},{\"from\":49.49,\"to\":54.13,\"location\":2,\"content\":\"您将了解什么是层以及为什么它们是良好网络设计的基本原理。 \"},{\"from\":54.13,\"to\":57.44,\"location\":2,\"content\":\"您将了解Internet的四个层次以及它们如何协同工作。 \"},{\"from\":57.44,\"to\":61.64,\"location\":2,\"content\":\"您将了解到大多数应用程序都使用称为传输的传输层\"},{\"from\":61.64,\"to\":66.22,\"location\":2,\"content\":\"控制协议或TCP,以及某些应用程序如何使用它。 \"},{\"from\":66.22,\"to\":70.63,\"location\":2,\"content\":\"您还将学到Internet通过将数据分解为称为\"},{\"from\":70.63,\"to\":71.63,\"location\":2,\"content\":\"包。 \"},{\"from\":71.63,\"to\":75.17,\"location\":2,\"content\":\"例如,当您请求网页时,计算机将一些数据包发送到网络\"},{\"from\":75.17,\"to\":76.17,\"location\":2,\"content\":\"服务器。 \"},{\"from\":76.17,\"to\":80.32,\"location\":2,\"content\":\"互联网决定这些数据包如何到达正确的目的地。 \"},{\"from\":80.32,\"to\":86.13,\"location\":2,\"content\":\"尼克:本单元还将详细检查称为网络层的一层。 \"},{\"from\":86.13,\"to\":88.45,\"location\":2,\"content\":\"您可能听说过IP,即Internet协议。 \"},{\"from\":88.45,\"to\":92.7,\"location\":2,\"content\":\"这是以Internet命名的协议,因为它是使整个过程变得完整的粘合剂\"},{\"from\":92.7,\"to\":93.98,\"location\":2,\"content\":\"事情工作。 \"},{\"from\":93.98,\"to\":98.54,\"location\":2,\"content\":\"您可以更改所有其他层,但是要使用Internet,您需要使用\"},{\"from\":98.54,\"to\":101.51,\"location\":2,\"content\":\"网络层的Internet协议。 \"},{\"from\":101.51,\"to\":105.28,\"location\":2,\"content\":\"您将了解Internet协议的功能以及它的工作方式。 \"},{\"from\":105.28,\"to\":108.83,\"location\":2,\"content\":\"您将了解Internet协议地址及其分配方式。 \"},{\"from\":108.83,\"to\":113.44,\"location\":2,\"content\":\"您将开始学习Internet如何根据Internet决定数据包应采用的路径\"},{\"from\":113.44,\"to\":114.44,\"location\":2,\"content\":\"地址。 \"},{\"from\":114.44,\"to\":119.33,\"location\":2,\"content\":\" Phil:最后,我们将向您展示一些软件工具,您可以使用这些工具来检查计算机的状态\"},{\"from\":119.33,\"to\":120.33,\"location\":2,\"content\":\"正在使用互联网。 \"},{\"from\":120.33,\"to\":123.92,\"location\":2,\"content\":\"因此,您可以将在本单元中学到的知识应用到下次浏览\"},{\"from\":123.92,\"to\":123.98,\"location\":2,\"content\":\"网络!\"}]}";
str = str.substring(str.indexOf("["), str.length() - 1);
strChinese = strChinese.substring(strChinese.indexOf("["), strChinese.length() - 1);
List<content> contents = JSON.parseArray(str, content.class);
List<content> contentsChiness = JSON.parseArray(strChinese, content.class);
for (int i = 0; i < contents.size(); i++) {
writer.addText(new Font("Times New Roman", Font.CENTER_BASELINE, 13), i + ": " + contents.get(i).getContent());
writer.addText(new Font("宋体", Font.TRUETYPE_FONT, 10), i + ": " + contentsChiness.get(i).getContent());
}
// 写出到文件
writer.flush(FileUtil.file("I:/"+System.currentTimeMillis()+".docx"));
// 关闭
writer.close();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。