-
大小: 36.12MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-08-08
- 语言: 其他
- 标签:
资源简介
在线画图www.draw.io网站的源码,基于mxGraph开发
代码片段和文件信息
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.linkedList;
import java.util.List;
import java.util.Set;
import java.util.zip.Deflater;
public class xml2Js
{
/**
*
*/
protected static final int IO_BUFFER_SIZE = 4 * 1024;
/**
*
*/
public static String CHARSET_FOR_URL_ENCODING = “ISO-8859-1“;
/**
*
* @param path
* @return
*/
public List walk(File base File root) throws IOException
{
if (root == null)
{
root = base;
}
List result = new linkedList();
String basePath = base.getCanonicalPath();
File[] list = root.listFiles();
if (list != null)
{
for (File f : list)
{
if (f.isDirectory())
{
result.addAll(walk(base f));
}
else if (f.getCanonicalPath().toLowerCase().endsWith(“.xml“))
{
String name = f.getCanonicalPath()
.substring(basePath.length() + 1);
result.add(
“f[‘“ + name + “‘] = ‘“ + processFile(f) + “‘;\n“);
}
}
}
return result;
}
/**
*
* @param file
* @return
* @throws IOException
*/
public static String processFile(File file) throws IOException
{
System.out.println(“Processing “ + file.getCanonicalPath() + “...“);
Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION true);
byte[] inBytes = encodeURIComponent(
readInputStream(new FileInputStream(file))
CHARSET_FOR_URL_ENCODING).getBytes(“UTF-8“);
deflater.setInput(inBytes);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(
inBytes.length);
deflater.finish();
byte[] buffer = new byte[IO_BUFFER_SIZE];
while (!deflater.finished())
{
int count = deflater.deflate(buffer); // returns the generated code... index
outputStream.write(buffer 0 count);
}
outputStream.close();
return encodeToString(outputStream.toByteArray() false);
}
/**
*
* @param stream
* @return
* @throws IOException
*/
public static String readInputStream(InputStream stream) throws IOException
{
BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
StringBuffer result = new StringBuffer();
String tmp = reader.readLine();
while (tmp != null)
{
result.append(tmp + “\n“);
tmp = reader.readLine();
}
reader.close();
return result.toString();
}
public static String encodeURIComponent(String s String charset)
{
if (s == null)
{
return null;
}
else
{
String result;
try
{
result = URLEncoder.encode(s charset).replaceAll(“\\+“ “%20“)
.replaceAll(“\\%21“ “!“).replaceAll(“\\%27“ “‘“)
.replaceAll(“\\%28“ “(“).replaceAll(“\\%29“ “)“)
.replaceAll(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\.github\
文件 699 2019-08-05 16:53 jgraph-drawio-e6d99f2\.github\stale.yml
文件 31 2019-08-05 16:53 jgraph-drawio-e6d99f2\.gitignore
文件 987 2019-08-05 16:53 jgraph-drawio-e6d99f2\.travis.yml
文件 180308 2019-08-05 16:53 jgraph-drawio-e6d99f2\ChangeLog
文件 11357 2019-08-05 16:53 jgraph-drawio-e6d99f2\LICENSE
文件 2000 2019-08-05 16:53 jgraph-drawio-e6d99f2\README.md
文件 6 2019-08-05 16:53 jgraph-drawio-e6d99f2\VERSION
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\
文件 6226 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\xm
文件 8407 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\xm
文件 263 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\build.properties
文件 15880 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\build.xm
文件 1340 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\cache.txt
文件 7131611 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\build\compiler.jar
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\docker\
文件 308 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\docker\Dockerfile
文件 494 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\docker\README.md
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\mxgraph\
文件 786392 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\mxgraph\mxClient.js
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\
文件 263 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\README
文件 421 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\build.xm
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\com\
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\com\mxgraph\
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\com\mxgraph\properties\
文件 5490 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\propgen\com\mxgraph\properties\PropGen.java
目录 0 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\sandstorm\
文件 416 2019-08-05 16:53 jgraph-drawio-e6d99f2\etc\sandstorm\ChangeLog
............此处省略3020个文件信息
评论
共有 条评论