Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
Expand All @@ -38,6 +37,8 @@

import com.apple.laf.AquaUtils.RecyclableSingleton;

import static java.nio.charset.StandardCharsets.UTF_8;

@SuppressWarnings("serial") // JDK implementation class
class AquaFileView extends FileView {
private static final boolean DEBUG = false;
Expand Down Expand Up @@ -115,7 +116,7 @@ static class FileInfo {
FileInfo(final File file){
isDirectory = file.isDirectory();
absolutePath = file.getAbsolutePath();
pathBytes = absolutePath.getBytes(StandardCharsets.UTF_8);
pathBytes = absolutePath.getBytes(UTF_8);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.text.Normalizer.Form;
import java.util.ArrayList;
Expand All @@ -46,6 +45,8 @@
import sun.awt.datatransfer.DataTransferer;
import sun.awt.datatransfer.ToolkitThreadBlockedHandler;

import static java.nio.charset.StandardCharsets.UTF_8;

public class CDataTransferer extends DataTransferer {
private static final Map<String, Long> predefinedClipboardNameMap;
private static final Map<Long, String> predefinedClipboardFormatMap;
Expand Down Expand Up @@ -138,7 +139,7 @@ public Object translateBytes(byte[] bytes, DataFlavor flavor,
String charset = Charset.defaultCharset().name();
if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
try {
charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), StandardCharsets.UTF_8);
charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), UTF_8);
} catch (UnsupportedFlavorException cannotHappen) {
}
}
Expand All @@ -165,9 +166,8 @@ public Object translateBytes(byte[] bytes, DataFlavor flavor,
// class by base method
format = CF_STRING;
} else if (format == CF_STRING) {
String src = new String(bytes, StandardCharsets.UTF_8);
String nfc = Normalizer.normalize(src, Form.NFC);
bytes = nfc.getBytes(StandardCharsets.UTF_8);
String src = new String(bytes, UTF_8);
bytes = Normalizer.normalize(src, Form.NFC).getBytes(UTF_8);
}

return super.translateBytes(bytes, flavor, format, transferable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

package com.sun.imageio.plugins.bmp;

import java.nio.charset.StandardCharsets;

import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.metadata.IIOMetadataNode;
Expand All @@ -35,6 +33,8 @@
import com.sun.imageio.plugins.common.ImageUtil;
import org.w3c.dom.Node;

import static java.nio.charset.StandardCharsets.ISO_8859_1;

public class BMPMetadata extends IIOMetadata implements BMPConstants {
public static final String nativeMetadataFormatName =
"javax_imageio_bmp_1.0";
Expand Down Expand Up @@ -110,7 +110,7 @@ public Node getAsTree(String formatName) {
}

private String toISO8859(byte[] data) {
return new String(data, StandardCharsets.ISO_8859_1);
return new String(data, ISO_8859_1);
}

private Node getNativeTree() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package com.sun.imageio.plugins.gif;

import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.List;

Expand All @@ -35,6 +34,8 @@

import org.w3c.dom.Node;

import static java.nio.charset.StandardCharsets.ISO_8859_1;

public class GIFImageMetadata extends GIFMetadata {

// package scope
Expand Down Expand Up @@ -130,7 +131,7 @@ public Node getAsTree(String formatName) {
}

private String toISO8859(byte[] data) {
return new String(data, StandardCharsets.ISO_8859_1);
return new String(data, ISO_8859_1);
}

private Node getNativeTree() {
Expand Down Expand Up @@ -378,7 +379,7 @@ public IIOMetadataNode getStandardTextNode() {

while (commentIter.hasNext()) {
byte[] comment = commentIter.next();
String s = new String(comment, StandardCharsets.ISO_8859_1);
String s = new String(comment, ISO_8859_1);

node = new IIOMetadataNode("TextEntry");
node.setAttribute("value", s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package com.sun.imageio.plugins.gif;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

import javax.imageio.metadata.IIOInvalidTreeException;
Expand All @@ -35,6 +34,8 @@

import org.w3c.dom.Node;

import static java.nio.charset.StandardCharsets.ISO_8859_1;

class GIFWritableImageMetadata extends GIFImageMetadata {

// package scope
Expand Down Expand Up @@ -92,7 +93,7 @@ public void reset() {
}

private byte[] fromISO8859(String data) {
return data.getBytes(StandardCharsets.ISO_8859_1);
return data.getBytes(ISO_8859_1);
}

protected void mergeNativeTree(Node root) throws IIOInvalidTreeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
package com.sun.imageio.plugins.jpeg;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.stream.ImageOutputStream;

import org.w3c.dom.Node;

import static java.nio.charset.StandardCharsets.ISO_8859_1;

/**
* A Comment marker segment. Retains an array of bytes representing the
* comment data as it is read from the stream. If the marker segment is
Expand Down Expand Up @@ -95,7 +96,7 @@ class COMMarkerSegment extends MarkerSegment {
* consulted directly.
*/
String getComment() {
return new String(data, StandardCharsets.ISO_8859_1);
return new String(data, ISO_8859_1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.awt.image.WritableRaster;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand All @@ -60,6 +59,8 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import static java.nio.charset.StandardCharsets.US_ASCII;

/**
* A JFIF (JPEG File Interchange Format) APP0 (Application-Specific)
* marker segment. Inner classes are included for JFXX extension
Expand Down Expand Up @@ -1353,7 +1354,7 @@ static void writeICC(ICC_Profile profile, ImageOutputStream ios)
ios.write(0xff);
ios.write(JPEG.APP2);
MarkerSegment.write2bytes(ios, segLength);
byte[] id = ID.getBytes(StandardCharsets.US_ASCII);
byte[] id = ID.getBytes(US_ASCII);
ios.write(id);
ios.write(0); // Null-terminate the string
ios.write(chunkNum++);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
Expand All @@ -63,6 +62,9 @@
import com.sun.imageio.plugins.common.SubImageInputStream;
import sun.awt.image.ByteInterleavedRaster;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;

class PNGImageDataEnumeration implements Enumeration<InputStream> {

boolean firstTime = true;
Expand Down Expand Up @@ -489,9 +491,9 @@ private void parse_iTXt_chunk(int chunkLength) throws IOException {
stream.readFully(b);

if (compressionFlag == 1) { // Decompress the text
text = new String(inflate(b), StandardCharsets.UTF_8);
text = new String(inflate(b), UTF_8);
} else {
text = new String(b, StandardCharsets.UTF_8);
text = new String(b, UTF_8);
}
metadata.iTXt_text.add(text);

Expand Down Expand Up @@ -592,7 +594,7 @@ private void parse_tEXt_chunk(int chunkLength) throws IOException {

byte[] b = new byte[textLength];
stream.readFully(b);
metadata.tEXt_text.add(new String(b, StandardCharsets.ISO_8859_1));
metadata.tEXt_text.add(new String(b, ISO_8859_1));

// Check if the text chunk contains image creation time
if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) {
Expand Down Expand Up @@ -693,8 +695,7 @@ private void parse_zTXt_chunk(int chunkLength) throws IOException {

byte[] b = new byte[textLength];
stream.readFully(b);
metadata.zTXt_text.add(new String(inflate(b),
StandardCharsets.ISO_8859_1));
metadata.zTXt_text.add(new String(inflate(b), ISO_8859_1));

// Check if the text chunk contains image creation time
if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.awt.image.WritableRaster;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.Locale;
import java.util.zip.Deflater;
Expand All @@ -49,6 +48,9 @@
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.ImageOutputStreamImpl;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;

final class CRC {

private static final int[] crcTable = new int[256];
Expand Down Expand Up @@ -803,16 +805,14 @@ private void write_iTXt() throws IOException {
cs.writeBytes(languageIter.next());
cs.writeByte(0);


cs.write(translatedKeywordIter.next()
.getBytes(StandardCharsets.UTF_8));
cs.write(translatedKeywordIter.next().getBytes(UTF_8));
cs.writeByte(0);

String text = textIter.next();
if (compressed) {
cs.write(deflate(text.getBytes(StandardCharsets.UTF_8)));
cs.write(deflate(text.getBytes(UTF_8)));
} else {
cs.write(text.getBytes(StandardCharsets.UTF_8));
cs.write(text.getBytes(UTF_8));
}
cs.finish();
}
Expand All @@ -836,7 +836,7 @@ private void write_zTXt() throws IOException {
cs.writeByte(compressionMethod);

String text = textIter.next();
cs.write(deflate(text.getBytes(StandardCharsets.ISO_8859_1)));
cs.write(deflate(text.getBytes(ISO_8859_1)));
cs.finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,24 +22,27 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.imageio.plugins.tiff;

import java.io.EOFException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.imageio.IIOException;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.plugins.tiff.BaselineTIFFTagSet;
import javax.imageio.plugins.tiff.TIFFDirectory;
import javax.imageio.plugins.tiff.TIFFField;
import javax.imageio.plugins.tiff.TIFFTag;
import javax.imageio.plugins.tiff.TIFFTagSet;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;

import static java.nio.charset.StandardCharsets.US_ASCII;

public class TIFFIFD extends TIFFDirectory {
private static final long MAX_SAMPLES_PER_PIXEL = 0xffff;
Expand Down Expand Up @@ -283,8 +286,7 @@ private static int readFieldValue(ImageInputStream stream,
if (inString) {
// end of string
String s = new String(bvalues, prevIndex,
index - prevIndex,
StandardCharsets.US_ASCII);
index - prevIndex, US_ASCII);
v.add(s);
inString = false;
}
Expand Down
Loading